Struct SigAction

Source
#[repr(C)]
pub struct SigAction { pub handler: usize, pub flags: usize, pub restorer: usize, pub mask: SigSet, }
Expand description

信号处理函数的结构体(对应 C 的 struct sigaction

MUSL: https://github.com/bminor/musl/blob/c47ad25ea3b484e10326f933e927c0bc8cded3da/src/internal/ksigaction.h#L6

Fields§

§handler: usize

信号处理函数指针,类似于 C 中的 void (*sa_handler)(int); 当信号发生时将调用此函数。也可以是特殊值,如 SIG_IGN 或 SIG_DFL。

§flags: usize

标志位,用于指定处理行为,如 SA_RESTART、SA_NOCLDSTOP 等。 对应 C 中的 int sa_flags;

§restorer: usize

系统调用的恢复函数指针,一般在使用自定义恢复机制时使用。 对应 C 中的 void (*sa_restorer)(void); 通常不使用,设为 0。

§mask: SigSet

一个信号集合,用于在处理该信号时阻塞的其他信号。 对应 C 中的 sigset_t sa_mask;

Implementations§

Source§

impl SigAction

Source

pub const SIG_DFL: usize = 0usize

表示使用该信号的默认处理方式(default action) 用于注册信号处理函数时,表示恢复默认行为(如终止进程等)。

Source

pub const SIG_IGN: usize = 1usize

表示忽略该信号(ignore) 用于注册信号处理函数时,表示收到该信号时不做任何处理。

Source

pub const fn empty() -> Self

创建一个新的信号处理函数结构体,所有字段初始化为默认值。

Trait Implementations§

Source§

impl Clone for SigAction

Source§

fn clone(&self) -> SigAction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SigAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.