diff --git a/bin/sh/trap.c b/bin/sh/trap.c index 00924804b951..836ce976414b 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -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; } /* diff --git a/bin/sh/trap.h b/bin/sh/trap.h index 8971e59de230..64abb12b420f 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -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));