From e83e43aaa5d3486d092057b6c9bcfe83ce43b36f Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 24 Mar 2012 18:47:04 +0000 Subject: [PATCH] =?UTF-8?q?block=20things=20like=20SIGWINCH=C2=B9=20during?= =?UTF-8?q?=20builtin=20sleep,=20they=20get=20rescheduled=20on=20unblock?= =?UTF-8?q?=20just=20fine=20and=20hurt=20since=20they=20interrupt=20select?= =?UTF-8?q?(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ① and² SIGPIPE, SIGINFO, SIGUSR{1,2} in addition to already blocked SIGCHLD ② exact list open for suggestions – I’ve got no idea what I’m doing… --- funcs.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/funcs.c b/funcs.c index e90e816..a248fb3 100644 --- a/funcs.c +++ b/funcs.c @@ -38,7 +38,7 @@ #endif #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.208 2012/03/03 19:28:45 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.209 2012/03/24 18:47:04 tg Exp $"); #if HAVE_KILLPG /* @@ -3660,10 +3660,25 @@ c_sleep(const char **wp) bi_errorf("%s: %s '%s'", Tsynerr, strerror(errno), wp[0]); else { #ifndef MKSH_NOPROSPECTOFWORK - sigset_t omask; + sigset_t omask, bmask; - /* block SIGCHLD from interrupting us, though */ - sigprocmask(SIG_BLOCK, &sm_sigchld, &omask); + /* block a number of signals from interrupting us, though */ + (void)sigemptyset(&bmask); + (void)sigaddset(&bmask, SIGPIPE); + (void)sigaddset(&bmask, SIGCHLD); +#ifdef SIGWINCH + (void)sigaddset(&bmask, SIGWINCH); +#endif +#ifdef SIGINFO + (void)sigaddset(&bmask, SIGINFO); +#endif +#ifdef SIGUSR1 + (void)sigaddset(&bmask, SIGUSR1); +#endif +#ifdef SIGUSR2 + (void)sigaddset(&bmask, SIGUSR2); +#endif + sigprocmask(SIG_BLOCK, &bmask, &omask); #endif if (select(1, NULL, NULL, NULL, &tv) == 0 || errno == EINTR) /* @@ -3674,6 +3689,7 @@ c_sleep(const char **wp) else bi_errorf("%s: %s", Tselect, strerror(errno)); #ifndef MKSH_NOPROSPECTOFWORK + /* this will re-schedule signal delivery */ sigprocmask(SIG_SETMASK, &omask, NULL); #endif }