diff options
Diffstat (limited to 'bin/sh/error.c')
-rw-r--r-- | bin/sh/error.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/bin/sh/error.c b/bin/sh/error.c index 9e383e3..0464f6e 100644 --- a/bin/sh/error.c +++ b/bin/sh/error.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id$"; + "$Id: error.c,v 1.10 1998/05/18 06:43:32 charnier Exp $"; #endif /* not lint */ /* @@ -52,6 +52,7 @@ static const char rcsid[] = #include "output.h" #include "error.h" #include "show.h" +#include "trap.h" #include <signal.h> #include <unistd.h> #include <errno.h> @@ -62,9 +63,9 @@ static const char rcsid[] = */ struct jmploc *handler; -int exception; -volatile int suppressint; -volatile int intpending; +volatile sig_atomic_t exception; +int suppressint; +volatile sig_atomic_t intpending; char *commandname; @@ -90,29 +91,43 @@ exraise(e) /* * Called from trap.c when a SIGINT is received. (If the user specifies * that SIGINT is to be trapped or ignored using the trap builtin, then - * this routine is not called.) Suppressint is nonzero when interrupts - * are held using the INTOFF macro. The call to _exit is necessary because - * there is a short period after a fork before the signal handlers are - * set to the appropriate value for the child. (The test for iflag is - * just defensive programming.) + * this routine is not called.) Supressint is nonzero when interrupts + * are held using the INTOFF macro. If SIGINTs are not suppressed and + * the shell is not a root shell, then we want to be terminated if we + * get here, as if we were terminated directly by a SIGINT. Arrange for + * this here. */ void onint() { sigset_t sigset; - if (suppressint) { + /* The !in_dotrap is save. The only way we can arrive here with + * in_dotrap set is that a trap handler set SIGINT to default + * and killed itself. + */ + + if (suppressint && !in_dotrap) { intpending++; return; } intpending = 0; sigemptyset(&sigset); sigprocmask(SIG_SETMASK, &sigset, NULL); - out2str("\n"); + + /* This doesn't seem to be needed. Note that main emit a newline + * as well. + */ +#if 0 + if (tcgetpgrp(0) == getpid()) + write(STDERR_FILENO, "\n", 1); +#endif if (rootshell && iflag) exraise(EXINT); - else - _exit(128 + SIGINT); + else { + signal(SIGINT, SIG_DFL); + kill(getpid(), SIGINT); + } } |