如附件。
Compared to sleep(3) and usleep(3), nanosleep() has the advantage of not affecting any signals, it is standardized by POSIX, it provides higher timing resolution, and it allows to continue a sleep that has been interrupted by a signal more easily.
Security issue:
[1] (obsolete) usleep:
This C routine is considered obsolete (as opposed to the shell command
by the same name). The interaction of this function with SIGALRM and
other timer functions such as sleep(), alarm(), setitimer(), and
nanosleep() is unspecified. Use nanosleep(2) or setitimer(2) instead.