summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/unistd/sleep.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/unistd/sleep.c b/src/unistd/sleep.c
index 29ffee7b..9af72481 100644
--- a/src/unistd/sleep.c
+++ b/src/unistd/sleep.c
@@ -1,15 +1,24 @@
#include "stddef.h"
#include "sys/types.h"
#include <unistd.h>
-#include "../_syscall.h"
+#include "time.h"
+
+#if _POSIX_C_SOURCE < 199309
+#define nanosleep __nanosleep
+#include "../time/struct_timespec.c"
+#include "../time/nanosleep.c"
+#endif
unsigned sleep(unsigned seconds)
{
- #if 0
- SC(unsigned, seconds);
- #else
- return seconds;
- #endif
+ struct timespec tosleep = { seconds, 0 };
+ struct timespec remaining = { 0 , 0 };
+
+ if (nanosleep(&tosleep, &remaining) == -1) {
+ return seconds;
+ }
+
+ return remaining.tv_sec;
}
/*
POSIX(1)