OSDN Git Service

Make sleep behave itself properly inthe presence of SIGCHLD
authorEric Andersen <andersen@codepoet.org>
Tue, 30 Dec 2003 10:45:45 +0000 (10:45 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 30 Dec 2003 10:45:45 +0000 (10:45 -0000)
libc/unistd/sleep.c
libc/unistd/usleep.c

index 2b3187e..20689da 100644 (file)
 #include <signal.h>
 #include <unistd.h>
 
-#if 1
+#if 0
 /* This is a quick and dirty, but not 100% compliant with
  * the stupid SysV SIGCHLD vs. SIG_IGN behaviour.  It is
  * fine unless you are messing with SIGCHLD...  */
 unsigned int sleep (unsigned int sec)
 {
        unsigned int res;
-       struct timespec ts = { 
-           tv_sec:  (long int) sec,
-           tv_nsec: 0 
-       };
+       struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
        res = nanosleep(&ts, &ts);
        if (res) res = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
        return res;
@@ -46,7 +43,7 @@ unsigned int sleep (unsigned int sec)
    behaviour for this syscall.  Therefore we have to emulate it here.  */
 unsigned int sleep (unsigned int seconds)
 {
-    struct timespec ts = { tv_sec: (long int) seconds, tv_nsec: 0 };
+    struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
     sigset_t set, oset;
     unsigned int result;
 
index 2597968..55e8f3f 100644 (file)
@@ -5,9 +5,9 @@
 
 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));
+    const struct timespec ts = {
+       .tv_sec = (long int) (usec / 1000000),
+       .tv_nsec = (long int) (usec % 1000000) * 1000ul
+    };
+    return(nanosleep(&ts, NULL));
 }
-