Ignore result of sigaction when setting traps. Traps will succeed even
on SIGKILL or SIGSTOP. This is what other bourne shells do. (suggested by mycroft)
This commit is contained in:
parent
5fb36cfb02
commit
9d255ec409
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.14 1995/06/05 14:24:33 christos Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.15 1995/06/07 04:16:57 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -38,9 +38,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)trap.c 8.4 (Berkeley) 6/5/95";
|
||||
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: trap.c,v 1.14 1995/06/05 14:24:33 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: trap.c,v 1.15 1995/06/07 04:16:57 christos Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -83,6 +83,8 @@ MKINIT char sigmode[NSIG]; /* current value of signal */
|
||||
char gotsig[NSIG]; /* indicates specified signal received */
|
||||
int pendingsigs; /* indicates some signal received */
|
||||
|
||||
static int getsigaction __P((int, sig_t *));
|
||||
|
||||
/*
|
||||
* The trap builtin.
|
||||
*/
|
||||
@ -162,7 +164,6 @@ setsignal(signo)
|
||||
sig_t sigact = SIG_DFL;
|
||||
char *t;
|
||||
extern void onsig();
|
||||
extern sig_t getsigaction();
|
||||
|
||||
if ((t = trap[signo]) == NULL)
|
||||
action = S_DFL;
|
||||
@ -200,16 +201,19 @@ setsignal(signo)
|
||||
}
|
||||
}
|
||||
|
||||
if (signo == SIGKILL)
|
||||
/* Pretend it worked */
|
||||
return 0;
|
||||
|
||||
t = &sigmode[signo - 1];
|
||||
if (*t == 0) {
|
||||
/*
|
||||
* current setting unknown
|
||||
*/
|
||||
sigact = getsigaction(signo);
|
||||
if (!getsigaction(signo, &sigact)) {
|
||||
/*
|
||||
* Pretend it worked; maybe we should give a warning
|
||||
* here, but other shells don't. We don't alter
|
||||
* sigmode, so that we retry every time.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
if (sigact == SIG_IGN) {
|
||||
if (mflag && (signo == SIGTSTP ||
|
||||
signo == SIGTTIN || signo == SIGTTOU)) {
|
||||
@ -234,16 +238,17 @@ setsignal(signo)
|
||||
/*
|
||||
* Return the current setting for sig w/o changing it.
|
||||
*/
|
||||
sig_t
|
||||
getsigaction(signo)
|
||||
static int
|
||||
getsigaction(signo, sigact)
|
||||
int signo;
|
||||
sig_t *sigact;
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
if (sigaction(signo, (struct sigaction *)0, &sa) == -1)
|
||||
error("Sigaction system call failed");
|
||||
|
||||
return (sig_t) sa.sa_handler;
|
||||
return 0;
|
||||
*sigact = (sig_t) sa.sa_handler;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.h,v 1.9 1995/05/11 21:30:32 christos Exp $ */
|
||||
/* $NetBSD: trap.h,v 1.10 1995/06/07 04:17:00 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)trap.h 8.2 (Berkeley) 5/4/95
|
||||
* @(#)trap.h 8.3 (Berkeley) 6/5/95
|
||||
*/
|
||||
|
||||
extern int pendingsigs;
|
||||
@ -43,7 +43,6 @@ extern int pendingsigs;
|
||||
int trapcmd __P((int, char **));
|
||||
void clear_traps __P((void));
|
||||
long setsignal __P((int));
|
||||
sig_t getsigaction __P((int));
|
||||
void ignoresig __P((int));
|
||||
void onsig __P((int));
|
||||
void dotrap __P((void));
|
||||
|
Loading…
Reference in New Issue
Block a user