Skip to content

Commit

Permalink
feat: make SigAction repr(transparent)&From<raw>&Into<raw> (#2326)
Browse files Browse the repository at this point in the history
* feat: make SigAction repr(transparent)&From<raw>&Into<raw>

* style: fix clippy
  • Loading branch information
SteveLauC authored Mar 16, 2024
1 parent a0078c1 commit 08e7849
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2326.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make SigAction repr(transparent) & can be converted to/from the libc raw type
14 changes: 14 additions & 0 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<libc::sigaction> for SigAction {
fn from(value: libc::sigaction) -> Self {
Self {
sigaction: value
}
}
}
impl From<SigAction> for libc::sigaction {
fn from(value: SigAction) -> libc::sigaction {
value.sigaction
}
}

impl SigAction {
/// Creates a new action.
///
Expand Down

0 comments on commit 08e7849

Please sign in to comment.