#[repr(C)]pub struct SigAction {
pub sa_handler: usize,
pub sa_flags: SigActionFlags,
pub restorer: usize,
pub sa_mask: usize,
}Expand description
The structure of the signal action
Fields§
§sa_handler: usize信号处理函数的地址
- 如果是上述特殊值 SIG_DFL 或 SIG_IGN,则按描述处理
- 若flags没有指定SA_SIGINFO,则函数原型为 fn(sig: SignalNo) -> (),对应C语言原型为 void (*sa_handler)(int)
- 若flags指定了SA_SIGINFO,则函数原型为 fn(sig: SignalNo, info: &SigInfo, ucontext: &mut UContext) -> (), 对应C语言原型为 void (*sa_sigaction)(int, siginfo_t *, void *)。
其中,SigInfo和SignalNo的定义见siginfo.rs和signal_no.rs。 UContext即是处理信号时内核保存的用户态上下文,它存储在用户地址空间,会在调用sig_return时被恢复,定义见ucontext.rs。
sa_flags: SigActionFlags信号处理的flags
restorer: usize信号处理的跳板页地址,存储了sig_return的函数处理地址 仅在SA_RESTORER标志被设置时有效
sa_mask: usize该信号处理函数的信号掩码
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for SigAction
impl Send for SigAction
impl Sync for SigAction
impl Unpin for SigAction
impl UnwindSafe for SigAction
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more