Hi Paul,
On 2011-07-16 you wrote:
> "sleep 0" sleeps for zero seconds, and "timeout 0 FOO"
> should timeout in zero seconds as well. Currently,
> it doesn't; it times out in an infinite number of seconds.
> I see why, from the internals (alarm (0) is a special
> call intended to cancel alarms). However, 'timeout' shouldn't
> be exposing those internals to users; it should behave like
> 'sleep' does, as that's more consistent.
POSIX-1.2024 standardized the following behavior [1]:
DESCRIPTION
[...]
If the value of the duration operand is non-zero and the child
process has not terminated after the specified time period,
timeout shall send the signal specified by the -s option, or the
SIGTERM signal if -s is not given.
OPERANDS
[...]
If the [duration] value is zero, timeout shall not enforce a time
limit.
Aside from us following this behavior for a long time, the BSD
implementations (and likely others) also behave this way. Therefore, I
think it is best to leave it alone since changing it would likely cause
problems.
Going to close this old bug report, since I assume you are likely to
agree.
Collin
[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/timeout.html