about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-05-01 09:35:04 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-05-01 09:35:04 +0000
commit6e5279f8b4ba43133cf1db1f76b8e536da98797d (patch)
treee4cbc45db2250c6cac01a76ab30f5ccf87ee59ac /Src/signals.c
parent19dccc355a3a6316a60abdb739bbec7f9ce9a362 (diff)
downloadzsh-6e5279f8b4ba43133cf1db1f76b8e536da98797d.tar.gz
zsh-6e5279f8b4ba43133cf1db1f76b8e536da98797d.tar.xz
zsh-6e5279f8b4ba43133cf1db1f76b8e536da98797d.zip
Guillaume Chazarain: 23364: fix race in POSIX signal blocking
by using local variables
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 8f5bc49b8..ba01e2bc9 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -200,15 +200,6 @@ signal_mask(int sig)
  * set. Return the old signal set.       */
 
 /**/
-#ifdef POSIX_SIGNALS
-
-/**/
-mod_export sigset_t dummy_sigset1, dummy_sigset2;
-
-/**/
-#else
-
-/**/
 #ifndef BSD_SIGNALS
 
 sigset_t
@@ -216,7 +207,11 @@ signal_block(sigset_t set)
 {
     sigset_t oset;
  
-#ifdef SYSV_SIGNALS
+#ifdef POSIX_SIGNALS
+    sigprocmask(SIG_BLOCK, &set, &oset);
+
+#else
+# ifdef SYSV_SIGNALS
     int i;
  
     oset = blocked_set;
@@ -226,7 +221,7 @@ signal_block(sigset_t set)
             sighold(i);
         }
     }
-#else  /* NO_SIGNAL_BLOCKING */
+# else  /* NO_SIGNAL_BLOCKING */
 /* We will just ignore signals if the system doesn't have *
  * the ability to block them.                             */
     int i;
@@ -238,7 +233,8 @@ signal_block(sigset_t set)
             signal_ignore(i);
         }
    }
-#endif /* SYSV_SIGNALS  */
+# endif /* SYSV_SIGNALS */
+#endif /* POSIX_SIGNALS */
  
     return oset;
 }
@@ -246,19 +242,17 @@ signal_block(sigset_t set)
 /**/
 #endif /* BSD_SIGNALS */
 
-/**/
-#endif /* POSIX_SIGNALS */
-
 /* Unblock the signals in the given signal *
  * set. Return the old signal set.         */
 
-#ifndef POSIX_SIGNALS
-
 sigset_t
 signal_unblock(sigset_t set)
 {
     sigset_t oset;
- 
+
+#ifdef POSIX_SIGNALS
+    sigprocmask(SIG_UNBLOCK, &set, &oset);
+#else
 # ifdef BSD_SIGNALS
     sigfillset(&oset);
     oset = sigsetmask(oset);
@@ -288,12 +282,11 @@ signal_unblock(sigset_t set)
    }
 #  endif /* SYSV_SIGNALS  */
 # endif  /* BSD_SIGNALS   */
+#endif   /* POSIX_SIGNALS */
  
     return oset;
 }
 
-#endif   /* POSIX_SIGNALS */
-
 /* set the process signal mask to *
  * be the given signal mask       */