Skip to content

Commit 08e7849

Browse files
authored
feat: make SigAction repr(transparent)&From<raw>&Into<raw> (#2326)
* feat: make SigAction repr(transparent)&From<raw>&Into<raw> * style: fix clippy
1 parent a0078c1 commit 08e7849

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

changelog/2326.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
make SigAction repr(transparent) & can be converted to/from the libc raw type

src/sys/signal.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,25 @@ pub enum SigHandler {
753753
}
754754

755755
/// Action to take on receipt of a signal. Corresponds to `sigaction`.
756+
#[repr(transparent)]
756757
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
757758
pub struct SigAction {
758759
sigaction: libc::sigaction
759760
}
760761

762+
impl From<libc::sigaction> for SigAction {
763+
fn from(value: libc::sigaction) -> Self {
764+
Self {
765+
sigaction: value
766+
}
767+
}
768+
}
769+
impl From<SigAction> for libc::sigaction {
770+
fn from(value: SigAction) -> libc::sigaction {
771+
value.sigaction
772+
}
773+
}
774+
761775
impl SigAction {
762776
/// Creates a new action.
763777
///

0 commit comments

Comments
 (0)