mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
timeout: ensure infinitesimal timeouts timeout quickly
* src/timeout.c (parse_duration): Clamp infinitesimal values to 1ns. * tests/timeout/timeout-large-parameters.sh: Add a test case. * NEWS: Mention the bug fix. Fixes https://bugs.gnu.org/77535
This commit is contained in:
4
NEWS
4
NEWS
@@ -23,6 +23,10 @@ GNU coreutils NEWS -*- outline -*-
|
||||
like with dangling symlinks on cygwin.
|
||||
[bug introduced in coreutils-9.6]
|
||||
|
||||
timeout would fail to timeout commands with infinitesimal timeouts.
|
||||
For example `timeout 1e-5000 sleep inf` would never timeout.
|
||||
[bug introduced with timeout in coreutils-7.0]
|
||||
|
||||
'who -m' now outputs entries for remote logins. Previously login
|
||||
entries prefixed with the service (like "sshd") were not matched.
|
||||
[bug introduced in coreutils-9.4]
|
||||
|
||||
@@ -371,6 +371,10 @@ parse_duration (char const *str)
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
|
||||
/* Clamp underflow to 1ns, as 0 disables the timeout. */
|
||||
if (duration == 0 && errno == ERANGE)
|
||||
duration = 1e-9;
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,4 +43,7 @@ timeout 2.34e+5d sleep 0 || fail=1
|
||||
timeout $LDBL_MAX sleep 0 || fail=1
|
||||
returns_ 125 timeout -- -$LDBL_MAX sleep 0 || fail=1
|
||||
|
||||
# Ensure underflow times out immediately
|
||||
returns_ 124 timeout 1e-5000 sleep 10 || fail=1
|
||||
|
||||
Exit $fail
|
||||
|
||||
Reference in New Issue
Block a user