Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make SigAction repr(transparent)&From<raw>&Into<raw> #2326

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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