SignalAction

Struct SignalAction 

Source
#[repr(C)]
pub struct SignalAction { pub __sa_handler: __SaHandler, pub sa_mask: u64, pub sa_flags: c_int, pub sa_restorer: *mut extern "C" fn(), }
Expand description

Linux/POSIX 信号处理动作结构体 (struct sigaction)

Fields§

§__sa_handler: __SaHandler

C: union { ... } __sa_handler 包含单参数或三参数信号处理函数指针。

§sa_mask: u64

C: sigset_t sa_mask 信号屏蔽字,在执行处理函数时将被自动添加到线程的阻塞集中。

§sa_flags: c_int

C: int sa_flags 信号处理行为标志 (如 SA_SIGINFO, SA_RESETHAND)。 注意:这里使用 i32 或 c_int 更符合 C 的 int 类型。

§sa_restorer: *mut extern "C" fn()

C: void (*sa_restorer)(void) 信号恢复函数指针。通常由 C 库设置,用于从信号处理器返回。

Implementations§

Source§

impl SignalAction

Source

pub unsafe fn sa_handler(&self) -> *mut extern "C" fn(c_int)

获取单参数信号处理器。 这是一个不安全操作,因为它访问联合体字段。

Source

pub unsafe fn sa_sigaction( &self, ) -> *mut extern "C" fn(c_int, *const SigInfoT, *mut c_void)

获取三参数信号处理器。 这是一个不安全操作,因为它访问联合体字段。

Source

pub fn is_siginfo(&self) -> bool

安全地检查是否设置了 SA_SIGINFO 标志。

Source

pub fn new( handler: *mut extern "C" fn(c_int), flags: SaFlags, mask: SignalFlags, ) -> Self

创建一个新的 SignalAction 实例。

§参数:
  • handler: 信号处理函数指针 (单参数)
  • flags: 信号处理行为标志
  • mask: 信号屏蔽字
§返回值:新的 SignalAction 实例

Trait Implementations§

Source§

impl Clone for SignalAction

Source§

fn clone(&self) -> SignalAction

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SignalAction

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SignalAction

Source§

fn default() -> Self

创建一个默认的 SignalAction 实例,使用 SIG_DFL 作为处理器,空标志和空屏蔽字。

Source§

impl Copy for SignalAction

Auto Trait Implementations§

§

impl Freeze for SignalAction

§

impl RefUnwindSafe for SignalAction

§

impl !Send for SignalAction

§

impl !Sync for SignalAction

§

impl Unpin for SignalAction

§

impl UnwindSafe for SignalAction

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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

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

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.