gtpc2m6xC/C++ Language Support User's Guide

sleep-Suspend the Calling Process

This function causes the calling process to be suspended until the specified amount of real time has elapsed or a signal is caught by the process and the signal handler returns.

Format

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

seconds
The number of seconds of sleep time. The maximum number of seconds is 65 535. A higher value can be specified, but a value of 65 535 will actually be used.

Normal Return

The sleep function is always successful.

If the sleep function returns because of the receipt of a signal, the return value is the number of seconds remaining. Otherwise, 0 is returned.

Error Return

Not applicable.

Programming Considerations

Examples

The following example waits for an incoming signal or waits up to 10 seconds.

#include <unistd.h>

·
·
·
/* Wait for an incoming signal or up to 10 seconds */ sleep (10);
·
·
·

Related Information