Name

sleep - Sleep for the specified number of seconds

Library

libc.lib

Synopsis

  #include <unistd.h>
  unsigned int sleep (unsigned int seconds);

Return values

If the sleep function returns because the requested time has elapsed, the value returned will be zero.

Detailed description

The sleep function suspends execution of the calling process until seconds seconds have elapse

Time interval is internally represented using 32 bit value(range +-2147483647). any time interval greater 2147483647, returns 0 without sleeping. Hence Maximum sleep time supported here is 35 minutes, 47 seconds.


Examples

/**
 * Detailed description: This test code shows usage of sleep system call , here sample code
 * sleeps for 2 seconds.
**/
#include <unistd.h>
int main()
{
  if(sleep(2) < 0 )  
  {
    printf("Sleep failed \n");
    return -1;
  }
  printf("Sleep successful");
  return 0;
}

         

Output

Sleep successful

         


See also

nanosleep

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top