Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

23. Timers and Sleeping > Suspending Execution for a Fixed Interval (Sleeping)

Suspending Execution for a Fixed Interval (Sleeping)

Sometimes, we want to suspend execution of a process for a fixed amount of time. While it is possible to do this using a combination of sigsuspend() and the timer functions already described, it is easier to use one of the sleep functions instead.

Low-Resolution Sleeping: sleep()

The sleep() function suspends execution of the calling process for the number of seconds specified in the seconds argument or until a signal is caught (thus interrupting the call).

#include <unistd.h>

unsigned int sleep(unsigned int seconds);

Note

Returns 0 on normal completion, or number of unslept seconds if prematurely terminated


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint