timeout: treat seconds counts like 'sleep' does
commit240a63375697be8f3ff0fb97aea35ef2fecf1f4d
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 16 Jul 2011 19:07:46 +0000 (16 12:07 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 16 Jul 2011 19:10:45 +0000 (16 12:10 -0700)
tree4a24d1c077bbe0ef3d552a20c4fd5c8d668405b1
parent2d9b49789fadd039d43e5c1b6d09bebcc075227f
timeout: treat seconds counts like 'sleep' does

Treat fractions as a request to round up to the next representable
value, and treat out-of-range values as maximal ones.  This is
consistent with how "sleep" works.  And this way, "timeout
999999999999999999d FOO" and "timeout 4.5 foo" are more likely to
do what the user wants.
* src/timeout.c: Include c-strtod.h and xstrtod.h, not xstrtol.h.
(apply_time_suffix): Change it to the way sleep.c's time_suffix
does things.  Maybe this function (identical in both programs,
other than its name) should be moved to a library?
(parse_duration): Return a maximal value on overflow.  Return
unsigned int, not unsigned long.  Allow fractions, which round
up to the next integer value.
* tests/misc/timeout-parameters: Adjust tests to match new behavior.
Add a very large number.
src/timeout.c
tests/misc/timeout-parameters