Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: infinite sleep (infinite blocking)

I use startx to start X which will evaluate my .xinitrc. In my .xinitrc I start my window manager using /usr/bin/mywm. Now, if I kill my WM (in order to f.e. test some other WM), X will terminate too because the .xinitrc script reached EOF. So I added this at the end of my .xinitrc:

while true; do sleep 10000; done 

This way X won't terminate if I kill my WM. Now my question: how can I do an infinite sleep instead of looping sleep? Is there a command which will kinda like freeze the script?

like image 908
watain Avatar asked May 29 '10 13:05

watain


People also ask

Is bash sleep blocking?

The bash shell does not have a builtin usleep command (nor does it have a builtin sleep command).

How do you stop an infinite loop in Git bash?

Infinite while Loop You can also use the true built-in or any other statement that always returns true. The while loop above will run indefinitely. You can terminate the loop by pressing CTRL+C .

What is sleep infinity in Linux?

Which results in: TIME_T_MAX = 9223372036854775807 . That is: sleep infinite results in an actual sleep time of 9223372036854775807 seconds (10^11 years). And for 32-bit linux systems ( sizeof(long) is 4 (32 bits)): 2147483647 seconds (68 years; see also year 2038 problem).

How do you sleep 10 seconds in shell script?

/bin/sleep is Linux or Unix command to delay for a specified amount of time. You can suspend the calling shell script for a specified time. For example, pause for 10 seconds or stop execution for 2 mintues. In other words, the sleep command pauses the execution on the next shell command for a given time.


1 Answers

sleep infinity does exactly what it suggests and works without cat abuse.

like image 191
Donarsson Avatar answered Oct 27 '22 14:10

Donarsson