GNU bug report logs -
#77535
timeout treats very short durations as `0`
Previous Next
Full log
Message #28 received at 77535 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 05/04/2025 19:45, Pádraig Brady wrote:
> On 05/04/2025 19:02, Philip Rowlands wrote:
>> I was interested to see that the code makes uses of strtod, and how this interacts with the minute / hour / day suffix.
>>
>> $ strace -e trace=clock_nanosleep sleep 3
>> clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=3, tv_nsec=0},
>>
>> $ strace -e trace=clock_nanosleep sleep 0xas
>> clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=10, tv_nsec=0},
>>
>> $ strace -e trace=clock_nanosleep sleep 0xam
>> clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=600, tv_nsec=0},
>>
>> $ strace -e trace=clock_nanosleep sleep 0xad
>> clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=173, tv_nsec=0},
>>
>> Here 0xad is interpreted as 173 seconds, not 10 days.
>>
>> It's a corner case, but should sleep(1) support or tolerate hex input, and if so, how should it handle the "d" suffix? FWIW I'd just vote to return an error for hex intervals.
>
> Good point :)
> Given FreeBSD and ksh sleep implementations also behave like GNU,
> we should probably just document the edge case that
> (day) suffixes are best avoided with hex inputs.
>
> ~$ ksh
> $ type sleep
> sleep is a shell builtin
> $ time sleep 0x10d
> real 4m29.00s
I'll apply the attached later to document this.
cheers,
Pádraig
[coreutils-hex-duration-suffixes.patch (text/x-patch, attachment)]
This bug report was last modified 42 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.