isblank() implementation.
[minix.git] / lib / libc / posix / _sleep.c
blobfe904292dfb405f62a0c8d8d1cc93f77b13c5841
1 /* sleep() - Sleep for a number of seconds. Author: Erik van der Kouwe
2 * 25 July 2009
3 * (Avoids interfering with alarm/setitimer by using select, like usleep)
4 */
6 #include <lib.h>
7 #define sleep _sleep
8 #include <unistd.h>
9 #include <errno.h>
10 #include <time.h>
11 #include <sys/select.h>
12 #include <sys/time.h>
14 unsigned sleep(unsigned sleep_seconds)
16 struct timespec rqtp, rmtp;
18 /* nanosleep implements this call; ignore failure, it cannot be reported */
19 rqtp.tv_sec = sleep_seconds;
20 rqtp.tv_nsec = 0;
21 nanosleep(&rqtp, &rmtp);
23 /* round remainder up to seconds */
24 return rmtp.tv_sec + ((rmtp.tv_nsec > 0) ? 1 : 0);