summaryrefslogtreecommitdiffstats
path: root/bin/sh/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/sh/trap.c')
-rw-r--r--bin/sh/trap.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/bin/sh/trap.c b/bin/sh/trap.c
index b21928f..c3ab48a 100644
--- a/bin/sh/trap.c
+++ b/bin/sh/trap.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: trap.c,v 1.11 1998/05/18 06:44:22 charnier Exp $";
#endif /* not lint */
#include <signal.h>
@@ -75,9 +75,11 @@ static const char rcsid[] =
MKINIT char sigmode[NSIG]; /* current value of signal */
-int pendingsigs; /* indicates some signal received */
+int pendingsigs; /* indicates some signal received */
+int in_dotrap = 0; /* Do we execute in a trap handler? */
static char *trap[NSIG]; /* trap handler commands */
-static char gotsig[NSIG]; /* indicates specified signal received */
+static volatile sig_atomic_t gotsig[NSIG];
+ /* indicates specified signal received */
static int ignore_sigchld; /* Used while handling SIGCHLD traps. */
static int getsigaction __P((int, sig_t *));
@@ -221,11 +223,10 @@ setsignal(signo)
action = S_CATCH;
else
action = S_IGN;
- if (rootshell && action == S_DFL) {
+ if (action == S_DFL) {
switch (signo) {
case SIGINT:
- if (iflag)
- action = S_CATCH;
+ action = S_CATCH;
break;
case SIGQUIT:
#ifdef DEBUG
@@ -236,15 +237,16 @@ setsignal(signo)
break;
}
#endif
- /* FALLTHROUGH */
+ action = S_IGN;
+ break;
case SIGTERM:
- if (iflag)
+ if (rootshell && iflag)
action = S_IGN;
break;
#if JOBS
case SIGTSTP:
case SIGTTOU:
- if (mflag)
+ if (rootshell && mflag)
action = S_IGN;
break;
#endif
@@ -356,6 +358,10 @@ onsig(signo)
if (signo != SIGCHLD || !ignore_sigchld)
gotsig[signo] = 1;
pendingsigs++;
+ if (signo == SIGINT && in_waitcmd != 0) {
+ dotrap();
+ breakwaitcmd = 1;
+ }
}
@@ -369,6 +375,7 @@ dotrap()
int i;
int savestatus;
+ in_dotrap++;
for (;;) {
for (i = 1; i < NSIG; i++) {
if (gotsig[i]) {
@@ -392,6 +399,7 @@ dotrap()
if (i >= NSIG)
break;
}
+ in_dotrap--;
pendingsigs = 0;
}
@@ -403,7 +411,7 @@ void
setinteractive(on)
int on;
{
- static int is_interactive = 0;
+ static int is_interactive = -1;
if (on == is_interactive)
return;
OpenPOWER on IntegriCloud