suspend a process for a given length of time
#include <unistd.h> unsigned int sleep( unsigned int seconds );
The sleep() function suspends the calling process until the number of realtime seconds specified by the seconds argument have elapsed, or a signal whose action is to either terminate the process or call a signal handler is received. The suspension time may be greater than the requested amount, due to the scheduling of other, higher priority activity by the system.
Zero if the full time specified was completed; otherwise the number of seconds remaining if interrupted by a signal.
If an error occurs, errno is set to indicate the type of error:
/* * The following program sleeps for the * number of seconds specified in argv[1]. */ #include <stdlib.h> #include <unistd.h> void main( int argc, char **argv ) { unsigned seconds; seconds = (unsigned) strtol( argv[1], NULL, 0 ); sleep( seconds ); }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
alarm(), delay(), errno, timer_create(), timer_gettime(), timer_settime()