Simplify code.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2008 19:34:47 +0000 (21:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jun 2008 19:34:47 +0000 (21:34 +0200)
ChangeLog
lib/nanosleep.c

index c9d6fa1..cce3c6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2008-06-22  Bruno Haible  <bruno@clisp.org>
 
+       * lib/nanosleep.c (rpl_nanosleep): Setup newact only when it is needed.
+
        * lib/sigprocmask.c: Update a comment.
 
 2008-06-21  Eric Blake  <ebb9@byu.net>
index 1732c59..e413c5d 100644 (file)
@@ -147,14 +147,18 @@ rpl_nanosleep (const struct timespec *requested_delay,
   /* set up sig handler */
   if (! initialized)
     {
-      struct sigaction oldact, newact;
-      newact.sa_handler = sighandler;
-      sigemptyset (&newact.sa_mask);
-      newact.sa_flags = 0;
+      struct sigaction oldact;
 
       sigaction (SIGCONT, NULL, &oldact);
       if (get_handler (&oldact) != SIG_IGN)
-       sigaction (SIGCONT, &newact, NULL);
+       {
+         struct sigaction newact;
+
+         newact.sa_handler = sighandler;
+         sigemptyset (&newact.sa_mask);
+         newact.sa_flags = 0;
+         sigaction (SIGCONT, &newact, NULL);
+       }
       initialized = true;
     }