blob: 10f067ff068c0859e83bf964409dbafd30616c08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
--- ksh-openbsd_cvs/trap.c 2010-02-23 12:49:23.000000000 +0100
+++ ksh-openbsd_cvs.new/trap.c 2010-04-01 21:30:25.819238979 +0200
@@ -5,6 +5,7 @@
*/
#include "sh.h"
+#include "posix_signals.h" /* sys_signame[] */
Trap sigtraps[NSIG + 1];
@@ -13,20 +14,29 @@ static struct sigaction Sigact_ign, Siga
void
inittraps(void)
{
- int i;
+ int i, j;
- /* Populate sigtraps based on sys_signame and sys_siglist. */
- for (i = 0; i <= NSIG; i++) {
+ /* Populate sigtraps based on posix_signals.h */
+ for (i = 1; i < NSIG; i++) {
sigtraps[i].signal = i;
if (i == SIGERR_) {
sigtraps[i].name = "ERR";
sigtraps[i].mess = "Error handler";
} else {
- sigtraps[i].name = sys_signame[i];
- sigtraps[i].mess = sys_siglist[i];
+ for(j = 0; j < NSIG; j++) /* find the corresponding SIGNAL number's name in the sys_signame[] array */
+ {
+ if( sys_signame[j].val == sigtraps[i].signal ) /* we got a match */
+ {
+ sigtraps[i].name = sys_signame[j].name;
+ break;
+ }
+ }
+ sigtraps[i].mess = strsignal(sigtraps[i].signal);
}
}
+ sigtraps[SIGEXIT_].signal = SIGEXIT_;
sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */
+ sigtraps[SIGEXIT_].mess = "Exited";
sigemptyset(&Sigact_ign.sa_mask);
Sigact_ign.sa_flags = 0; /* interruptible */
|