diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-01-02 12:10:01 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-01-02 12:10:01 +0000 |
commit | 5572db65ce5a2d0d159ec3ba20d47934303915cb (patch) | |
tree | ecdf7d274b7518333c4924bf106baceb6747f64f /libc/unistd/usleep.c | |
parent | 822a5d2922336680f23a68cf203a3264c8b4d152 (diff) |
Fix usleep to work correctly. Fix sleep behavior in the
presence of SIGCHLD.
-Erik
Diffstat (limited to 'libc/unistd/usleep.c')
-rw-r--r-- | libc/unistd/usleep.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c new file mode 100644 index 000000000..25979681d --- /dev/null +++ b/libc/unistd/usleep.c @@ -0,0 +1,13 @@ +#include <time.h> +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> + +int usleep (__useconds_t usec) +{ + const struct timespec ts = { + tv_sec: (long int)(usec / 1000000), + tv_nsec: (long int) (usec % 1000000) * 1000ul }; + return(nanosleep(&ts, NULL)); +} + |