Skip to content

Commit

Permalink
fix: use signal constants from nix (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Nov 28, 2024
1 parent 7ff3a48 commit 7f0ffc9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/shell/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,17 @@ impl SignalKind {

impl From<i32> for SignalKind {
fn from(value: i32) -> Self {
#[cfg(unix)]
match value {
nix::libc::SIGINT => SignalKind::SIGINT,
nix::libc::SIGQUIT => SignalKind::SIGQUIT,
nix::libc::SIGABRT => SignalKind::SIGABRT,
nix::libc::SIGKILL => SignalKind::SIGKILL,
nix::libc::SIGTERM => SignalKind::SIGTERM,
nix::libc::SIGSTOP => SignalKind::SIGSTOP,
_ => SignalKind::Other(value),
}
#[cfg(not(unix))]
match value {
2 => SignalKind::SIGINT,
3 => SignalKind::SIGQUIT,
Expand All @@ -608,6 +619,17 @@ impl From<i32> for SignalKind {

impl From<SignalKind> for i32 {
fn from(kind: SignalKind) -> i32 {
#[cfg(unix)]
match kind {
SignalKind::SIGINT => nix::libc::SIGINT,
SignalKind::SIGQUIT => nix::libc::SIGQUIT,
SignalKind::SIGABRT => nix::libc::SIGABRT,
SignalKind::SIGKILL => nix::libc::SIGKILL,
SignalKind::SIGTERM => nix::libc::SIGTERM,
SignalKind::SIGSTOP => nix::libc::SIGSTOP,
SignalKind::Other(value) => value,
}
#[cfg(not(unix))]
match kind {
SignalKind::SIGINT => 2,
SignalKind::SIGQUIT => 3,
Expand Down

0 comments on commit 7f0ffc9

Please sign in to comment.