Quoted from QNX document.
— delay(unsigned int duration) suspends the calling thread for duration milliseconds.
— sleep(unsigned int seconds) function suspends the calling thread until the number of realtime seconds specified by the seconds argument have elapsed, or the thread receives a signal whose action is either to terminate the process or to call a signal handler.
both delay() and sleep() returns either 0 or the number of unslept time if interrupt by a signal.
— usleep(useconds_t useconds) function suspends the calling thread until useconds microseconds of realtime have elapsed, or until a signal that isn’t ignored is received.
— nanosleep( const struct timespec* rqtp, struct timespec* rmtp ) function causes the calling thread to be suspended from execution until either:
- The time interval specified by the rqtp argument has elapsed
- A signal is delivered to the thread, and the signal’s action is to invoke a signal-catching function or terminate the process.
usleep() and nanosleep() returns either 0 (success) or -1 (an error occured)