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

expose si_status for SIGCHLD #166

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signal-hook"
version = "0.3.17"
version = "0.4.0"
authors = [
"Michal 'vorner' Vaner <[email protected]>",
"Thomas Himmelstoss <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions signal-hook-async-std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signal-hook-async-std"
version = "0.2.2"
version = "0.2.3"
authors = [
"Michal 'vorner' Vaner <[email protected]>",
"Thomas Himmelstoss <[email protected]>",
Expand All @@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" }
libc = "~0.2"
async-io = "~1"
futures-lite = "~1"
signal-hook = { version = "~0.3", path = ".." }
signal-hook = { version = "~0.4", path = ".." }

[dev-dependencies]
async-std = { version = "~1", features = ["attributes"] }
Expand Down
4 changes: 2 additions & 2 deletions signal-hook-mio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signal-hook-mio"
version = "0.2.4"
version = "0.2.5"
authors = [
"Michal 'vorner' Vaner <[email protected]>",
"Thomas Himmelstoss <[email protected]>",
Expand All @@ -27,7 +27,7 @@ support-v1_0 = ["mio-1_0"]

[dependencies]
libc = "~0.2"
signal-hook = { version = "~0.3", path = ".." }
signal-hook = { version = "~0.4", path = ".." }
mio-1_0 = { package = "mio", version = "~1.0", features = ["net", "os-ext"], optional = true }
mio-0_8 = { package = "mio", version = "~0.8", features = ["net", "os-ext"], optional = true }
mio-0_7 = { package = "mio", version = "~0.7", features = ["os-util", "uds"], optional = true }
Expand Down
4 changes: 2 additions & 2 deletions signal-hook-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signal-hook-registry"
version = "1.4.2"
version = "1.4.3"
authors = [
"Michal 'vorner' Vaner <[email protected]>",
"Masaki Hara <[email protected]>",
Expand All @@ -21,4 +21,4 @@ maintenance = { status = "actively-developed" }
libc = "~0.2"

[dev-dependencies]
signal-hook = { version = "~0.3", path = ".." }
signal-hook = { version = "~0.4", path = ".." }
4 changes: 2 additions & 2 deletions signal-hook-tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "signal-hook-tokio"
version = "0.3.1"
version = "0.3.2"
authors = [
"Michal 'vorner' Vaner <[email protected]>",
"Thomas Himmelstoss <[email protected]>",
Expand All @@ -24,7 +24,7 @@ futures-v0_3 = ["futures-core-0_3"]

[dependencies]
libc = "~0.2"
signal-hook = { version = "~0.3", path = ".." }
signal-hook = { version = "~0.4", path = ".." }
futures-core-0_3 = { package = "futures-core", version = "~0.3", optional = true }
tokio = { version = "~1", features = ["net"] }

Expand Down
5 changes: 5 additions & 0 deletions src/low_level/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ pid_t sighook_signal_pid(const siginfo_t *info) {
uid_t sighook_signal_uid(const siginfo_t *info) {
return info->si_uid;
}

c_int sighook_signal_status(const siginfo_t *info, bool *has_status) {
*has_status = info->si_signo == SIGCHLD;
return info->si_status;
}
7 changes: 7 additions & 0 deletions src/low_level/siginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern "C" {
fn sighook_signal_cause(info: &siginfo_t) -> ICause;
fn sighook_signal_pid(info: &siginfo_t) -> pid_t;
fn sighook_signal_uid(info: &siginfo_t) -> uid_t;
fn sighook_signal_status(info: &siginfo_t, has_status: &mut bool) -> c_int;
}

// Warning: must be in sync with the C code
Expand Down Expand Up @@ -66,6 +67,9 @@ pub struct Process {

/// The user owning the process.
pub uid: uid_t,

/// The exit status of the process, or the signal number that caused it to change state.
pub status: Option<c_int>,
}

impl Process {
Expand All @@ -78,9 +82,12 @@ impl Process {
* and `si_uid` filled in.
*/
unsafe fn extract(info: &siginfo_t) -> Self {
let mut has_status = false;
let status = sighook_signal_status(info, &mut has_status);
Self {
pid: sighook_signal_pid(info),
uid: sighook_signal_uid(info),
status: has_status.then_some(status),
}
}
}
Expand Down
Loading