sleep infinity

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

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.

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.

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.

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.

That explains everything. :slight_smile: Thank you.

thanks for the help...