LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sleep indefinitely (https://www.linuxquestions.org/questions/linux-newbie-8/sleep-indefinitely-704953/)

abhijitd 02-16-2009 12:49 AM

Sleep indefinitely
 
Hello all,

I am new to the Linux world. I have a small query. I have written a C program, wherein, I want to sleep/wait for ever in one of the function calls.

I had used sleep(-1) for that. I could have used something like,
while(1);
But, with while(1) cpu resources would continue to be used.

I am not sure if that is correct to use sleep(-1) or there are better ways of doing this. Can you guys please suggest?

Thank you

stevexyz 02-16-2009 03:37 AM

Maybe you could put the two together?
while ( 1 )
sleep(3600);
Steve


All times are GMT -5. The time now is 08:59 AM.