Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sleep function in c, unix

Tags:

c

unix

What do i need to import to use the sleep function in unix? i know it's windows.h for windows, but what about unix?

like image 486
rach Avatar asked Dec 17 '22 17:12

rach


2 Answers

It should be in unistd.h.

Please note that this gives you only a precision of integral seconds.

The most portable way for sub-second precision should be (ab-)using select().

like image 83
sstn Avatar answered Dec 23 '22 13:12

sstn


#include <unistd.h>
  • http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html
like image 43
miku Avatar answered Dec 23 '22 12:12

miku