1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 17:24:50 +01:00

Guillaume Chazarain: 23364: fix race in POSIX signal blocking

by using local variables
This commit is contained in:
Peter Stephenson 2007-05-01 09:35:04 +00:00
parent 19dccc355a
commit 6e5279f8b4
3 changed files with 21 additions and 40 deletions

View file

@ -1,5 +1,9 @@
2007-05-01 Peter Stephenson <pws@csr.com>
* Guillaume Chazarain: 23364: Src/signals.c, Src/signals.h: fix
race in POSIX signal blocking - use local variables as other forms
already do.
* 23363: README (not posted), Doc/Zsh/compsys.yo,
Src/Zle/computil.c: fake-files style now takes pattern.

View file

@ -199,15 +199,6 @@ signal_mask(int sig)
/* Block the signals in the given signal *
* set. Return the old signal set. */
/**/
#ifdef POSIX_SIGNALS
/**/
mod_export sigset_t dummy_sigset1, dummy_sigset2;
/**/
#else
/**/
#ifndef BSD_SIGNALS
@ -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 */

View file

@ -100,26 +100,10 @@
#define restore_queue_signals(q) (queueing_enabled = (q))
/* Make some signal functions faster. */
#ifdef POSIX_SIGNALS
#define signal_block(S) \
((dummy_sigset1 = (S)), \
sigprocmask(SIG_BLOCK, &dummy_sigset1, &dummy_sigset2), \
dummy_sigset2)
#else
# ifdef BSD_SIGNALS
#ifdef BSD_SIGNALS
#define signal_block(S) sigblock(S)
# else
extern sigset_t signal_block _((sigset_t));
# endif /* BSD_SIGNALS */
#endif /* POSIX_SIGNALS */
#ifdef POSIX_SIGNALS
#define signal_unblock(S) \
((dummy_sigset1 = (S)), \
sigprocmask(SIG_UNBLOCK, &dummy_sigset1, &dummy_sigset2), \
dummy_sigset2)
#else
extern sigset_t signal_block _((sigset_t));
#endif /* BSD_SIGNALS */
extern sigset_t signal_unblock _((sigset_t));
#endif /* POSIX_SIGNALS */