Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sleep indefinitely

Tags:

c

sleep

I was wondering if there is a statement which I can use to have a program sleep indefinitely (probably using sleep function??). (I am obviously doing this waiting for a signal that is going to be delivered at some time to this process and it will wake it up)

like image 226
nikos Avatar asked May 03 '11 13:05

nikos


People also ask

What is sleep Infinity command?

Linux command — `$ sleep infinity` is for forever sleeping ( never awake until escape )

How do I put sleep in a bash script?

How to Use the Bash Sleep Command. Sleep is a very versatile command with a very simple syntax. It is as easy as typing sleep N . This will pause your script for N seconds, with N being either a positive integer or a floating point number.


3 Answers

You want pause().

EDIT: The most likely circumstances under which you might want to use pause() will actually cause a race condition, so prefer sigsuspend().

like image 194
j_random_hacker Avatar answered Oct 16 '22 21:10

j_random_hacker


On Unix, see either pause or sigsuspend.

like image 34
aschepler Avatar answered Oct 16 '22 21:10

aschepler


And on Windows use Sleep(INFINITE)

like image 1
SmacL Avatar answered Oct 16 '22 20:10

SmacL