In article <
87po38n...@LkoBDZeT.terraraq.uk>,
Richard Kettlewell <inv...@invalid.invalid> wrote:
>
gaz...@shell.xmission.com (Kenny McCormack) writes:
>> Anyway, back to "GNU sleep", I was curious as to how "infinity" was
>> actually implemented and was a bit surprised by what I found.
>>
>> $ strace sleep infinity
>> (lots of stuff, ending with)
>> munmap(0x7f0e4f66e000, 81202) = 0
>> brk(NULL) = 0x178e000
>> brk(0x17af000) = 0x17af000
>> nanosleep({2073600, 999999999},
>>
>> Which leads to the question: What is 2073600???
...
> /* nanosleep mishandles large sleeps due to internal overflow problems.
> The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
> can’t sleep more than 24.85 days (2^31 milliseconds). Similarly,
> cygwin 1.5.x, which can’t sleep more than 49.7 days (2^32 milliseconds).
> Solve this by breaking the sleep up into smaller chunks. */
I see. Which leads to:
1) Why not just use pause(2)? That's what I'd use if I were coding an
infinite sleep.
2) Why not fix the (kernel) bugs?
I had intended to mention pause(2) in the OP, but forgot to do so.
>> P.S. To make this even more mysterious, I searched in sleep.c and
>> found no instances of the string "infinity", which makes me wonder
>> how/why this works at all...
>
>You need to look deeper than sleep.c.
Yeah, I figured it was probably in some other bit of source. Obviously, I
didn't intend on spending too much time digging.
>If you happen to start reading
>documentation rather than code, skip the man pages (which aren't all
>quite accurate in Linux) and use the info docs instead.
I see. Which leads to:
1) I don't do info. I know it is better, but I can't stand the interface.
2) Why not fix the man pages?
Anyway, thanks for responding. Very helpful.
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Rorschach