| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: trap.c,v 1.40.2.1 2017/07/23 14:58:14 snj Exp $ */ | | 1 | /* $NetBSD: trap.c,v 1.40.2.2 2018/08/25 14:41:21 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1991, 1993 | | 4 | * Copyright (c) 1991, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Kenneth Almquist. | | 8 | * Kenneth Almquist. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #ifndef lint | | 36 | #ifndef lint |
37 | #if 0 | | 37 | #if 0 |
38 | static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; | | 38 | static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; |
39 | #else | | 39 | #else |
40 | __RCSID("$NetBSD: trap.c,v 1.40.2.1 2017/07/23 14:58:14 snj Exp $"); | | 40 | __RCSID("$NetBSD: trap.c,v 1.40.2.2 2018/08/25 14:41:21 martin Exp $"); |
41 | #endif | | 41 | #endif |
42 | #endif /* not lint */ | | 42 | #endif /* not lint */ |
43 | | | 43 | |
44 | #include <signal.h> | | 44 | #include <signal.h> |
45 | #include <unistd.h> | | 45 | #include <unistd.h> |
46 | #include <stdlib.h> | | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | | 47 | #include <stdio.h> |
48 | | | 48 | |
49 | #include "shell.h" | | 49 | #include "shell.h" |
50 | #include "main.h" | | 50 | #include "main.h" |
51 | #include "nodes.h" /* for other headers */ | | 51 | #include "nodes.h" /* for other headers */ |
52 | #include "eval.h" | | 52 | #include "eval.h" |
53 | #include "jobs.h" | | 53 | #include "jobs.h" |
| @@ -513,29 +513,31 @@ dotrap(void) | | | @@ -513,29 +513,31 @@ dotrap(void) |
513 | for (;;) { | | 513 | for (;;) { |
514 | for (i = 1 ; ; i++) { | | 514 | for (i = 1 ; ; i++) { |
515 | if (i >= NSIG) { | | 515 | if (i >= NSIG) { |
516 | pendingsigs = 0; | | 516 | pendingsigs = 0; |
517 | return; | | 517 | return; |
518 | } | | 518 | } |
519 | if (gotsig[i]) | | 519 | if (gotsig[i]) |
520 | break; | | 520 | break; |
521 | } | | 521 | } |
522 | gotsig[i] = 0; | | 522 | gotsig[i] = 0; |
523 | savestatus=exitstatus; | | 523 | savestatus=exitstatus; |
524 | CTRACE(DBG_TRAP|DBG_SIG, ("dotrap %d: \"%s\"\n", i, | | 524 | CTRACE(DBG_TRAP|DBG_SIG, ("dotrap %d: \"%s\"\n", i, |
525 | trap[i] ? trap[i] : "-NULL-")); | | 525 | trap[i] ? trap[i] : "-NULL-")); |
526 | tr = savestr(trap[i]); /* trap code may free trap[i] */ | | 526 | if ((tr = trap[i]) != NULL) { |
527 | evalstring(tr, 0); | | 527 | tr = savestr(tr); /* trap code may free trap[i] */ |
528 | ckfree(tr); | | 528 | evalstring(tr, 0); |
| | | 529 | ckfree(tr); |
| | | 530 | } |
529 | exitstatus=savestatus; | | 531 | exitstatus=savestatus; |
530 | } | | 532 | } |
531 | } | | 533 | } |
532 | | | 534 | |
533 | int | | 535 | int |
534 | lastsig(void) | | 536 | lastsig(void) |
535 | { | | 537 | { |
536 | int i; | | 538 | int i; |
537 | | | 539 | |
538 | for (i = NSIG; --i > 0; ) | | 540 | for (i = NSIG; --i > 0; ) |
539 | if (gotsig[i]) | | 541 | if (gotsig[i]) |
540 | return i; | | 542 | return i; |
541 | return SIGINT; /* XXX */ | | 543 | return SIGINT; /* XXX */ |