1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

timeout: fix bug in --preserve-status mode

Fix a bug where `timeout --preserve-status` was not correctly
preserving the status code of the child process if it timed out. When
that happens, the status code of the child process is considered to be
the signal number (in this case, `SIGTERM`). The exit status of
`timeout` is then 128 plus the numeric code associated with `SIGTERM`.
This commit is contained in:
Jeffrey Finkelstein 2022-03-11 22:40:47 -05:00
parent 2d390233fe
commit 1aa6fd1468
2 changed files with 18 additions and 1 deletions

View file

@ -53,3 +53,14 @@ fn test_command_empty_args() {
.fails()
.stderr_contains("timeout: empty string");
}
#[test]
fn test_preserve_status() {
new_ucmd!()
.args(&["--preserve-status", ".1", "sleep", "10"])
.fails()
// 128 + SIGTERM = 128 + 15
.code_is(128 + 15)
.no_stderr()
.no_stdout();
}