1 #include <time.h> 2 #include <unistd.h> 3 sleep(unsigned int seconds)4unsigned int sleep (unsigned int seconds) 5 { 6 unsigned int res; 7 struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 }; 8 res = nanosleep(&ts, &ts); 9 if (res) res = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L); 10 return res; 11 } 12 13