diff --git a/changelog/2326.added.md b/changelog/2326.added.md new file mode 100644 index 0000000000..bcc29cb3db --- /dev/null +++ b/changelog/2326.added.md @@ -0,0 +1 @@ +make SigAction repr(transparent) & can be converted to/from the libc raw type diff --git a/src/sys/signal.rs b/src/sys/signal.rs index c9b593d0db..2a9c0027a9 100644 --- a/src/sys/signal.rs +++ b/src/sys/signal.rs @@ -753,11 +753,25 @@ pub enum SigHandler { } /// Action to take on receipt of a signal. Corresponds to `sigaction`. +#[repr(transparent)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct SigAction { sigaction: libc::sigaction } +impl From for SigAction { + fn from(value: libc::sigaction) -> Self { + Self { + sigaction: value + } + } +} +impl From for libc::sigaction { + fn from(value: SigAction) -> libc::sigaction { + value.sigaction + } +} + impl SigAction { /// Creates a new action. ///