This might be one of the dumbest questions you've got, but please bear with me:
I am a UNIX beginner. I had an test today and I was asked the following question:
Q. How do you put the terminal into sleep indefinitely?
I didn't know the answer, but after I came home, I tried the following command:
sleep infinity
it seems that this command puts the terminal to sleep till infinity. (or until you close the terminal or interrupt with Ctrl+C)
I just wanted to know, if this works in other systems too and if there is any other way to sleep indefinitely
thegeek
February 5, 2010, 11:14pm
2
Same behavior for me too..
I'm pretty new to Unix myself, so I checked in the GNU Coreutils documentation, and there is no infinity option there.
My only thought is that sleep is reading "infinity" as a large integer, rather than as a string.
drl
February 6, 2010, 6:25am
4
Hi.
What happens when you try GNU sleep with successive characters from the string infinity ? ... cheers, drl
'sleep inf' works as well. :-/
Everything else gives: sleep: invalid time interval '-infin'
Weird.
hergp
February 8, 2010, 5:38am
6
GNU sleep accepts float numbers as argument. According to the POSIX specs, the literals "inf" or "infinity" are possible string representations of a float number.
See: POSIX specs at strtod
The same is true for the sleep builtin function in the kornshell 93 which also accepts floats as arguments.
drl
February 8, 2010, 7:32am
7
Hi.
An example c program is at http://users.tkk.fi/jhi/infnan.c ... cheers, drl
Or you could send a SIGSTOP to your terminal from outside with KILL, which will stop it indefinitely until it receives another signal.
hergp:
GNU sleep accepts float numbers as argument. According to the POSIX specs, the literals "inf" or "infinity" are possible string representations of a float number.
See: POSIX specs at strtod
The same is true for the sleep builtin function in the kornshell 93 which also accepts floats as arguments.
That explains everything. Thank you.