LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2009, 12:49 AM   #1
abhijitd
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Rep: Reputation: 0
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
 
Old 02-16-2009, 03:37 AM   #2
stevexyz
LQ Newbie
 
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

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


Reply

Tags
sleep



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Server randomly hangs indefinitely bdb4269 Linux - General 2 03-07-2008 01:24 PM
How do I pause a thread indefinitely and then resume it again (in Java)? Nylex Programming 7 02-18-2007 12:13 PM
LXer: Free EHR Software from HHS Delayed Indefinitely LXer Syndicated Linux News 0 07-01-2006 10:33 PM
Searching for Server (BOOTP/DHCP) <sleep> <sleep> .. .. Eileen Linux - Networking 12 10-21-2005 01:14 AM
logrotate takes up 100% CPU indefinitely BroX Slackware 2 05-24-2005 03:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration