mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 21:47:46 +00:00
timeout: disable pre-existing SIGCHLD handlers
Needed to make a GNU test pass
This commit is contained in:
parent
0f9bc8e974
commit
b4efd5a749
3 changed files with 17 additions and 1 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "Inflector"
|
name = "Inflector"
|
||||||
version = "0.11.4"
|
version = "0.11.4"
|
||||||
|
@ -2606,6 +2608,7 @@ version = "0.0.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"libc",
|
"libc",
|
||||||
|
"nix 0.20.0",
|
||||||
"uucore",
|
"uucore",
|
||||||
"uucore_procs",
|
"uucore_procs",
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,6 +17,7 @@ path = "src/timeout.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
libc = "0.2.42"
|
libc = "0.2.42"
|
||||||
|
nix = "0.20.0"
|
||||||
uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["parse_time", "process", "signals"] }
|
uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["parse_time", "process", "signals"] }
|
||||||
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// * For the full copyright and license information, please view the LICENSE
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
// spell-checker:ignore (ToDO) tstr sigstr cmdname setpgid
|
// spell-checker:ignore (ToDO) tstr sigstr cmdname setpgid sigchld
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
@ -161,6 +161,17 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove pre-existing SIGCHLD handlers that would make waiting for the child's exit code fail.
|
||||||
|
fn unblock_sigchld() {
|
||||||
|
unsafe {
|
||||||
|
nix::sys::signal::signal(
|
||||||
|
nix::sys::signal::Signal::SIGCHLD,
|
||||||
|
nix::sys::signal::SigHandler::SigDfl,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes.
|
/// TODO: Improve exit codes, and make them consistent with the GNU Coreutils exit codes.
|
||||||
|
|
||||||
fn timeout(
|
fn timeout(
|
||||||
|
@ -194,6 +205,7 @@ fn timeout(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
unblock_sigchld();
|
||||||
match process.wait_or_timeout(duration) {
|
match process.wait_or_timeout(duration) {
|
||||||
Ok(Some(status)) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
Ok(Some(status)) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue