Commit | Line | Data |
---|---|---|
3084bb00 JL |
1 | # include "signal.h" |
2 | #undef NSIG | |
3 | # ifdef PWB | |
4 | #define NSIG 16 | |
5 | # else | |
6 | #define NSIG 4 | |
7 | # endif | |
8 | # include "../hdr/macros.h" | |
9 | SCCSID(@(#)setsig 2.1); | |
10 | ||
11 | /* | |
12 | General-purpose signal setting routine. | |
13 | All non-ignored, non-caught signals are caught. | |
14 | If a signal other than hangup, interrupt, or quit is caught, | |
15 | a "user-oriented" message is printed on file descriptor 2 with | |
16 | a number for help(I). | |
17 | If hangup, interrupt or quit is caught, that signal | |
18 | is set to ignore. | |
19 | Termination is like that of "fatal", | |
20 | via "clean_up(sig)" (sig is the signal number) | |
21 | and "exit(userexit(1))". | |
22 | ||
23 | If the file "dump.core" exists in the current directory | |
24 | the function commits | |
25 | suicide to produce a core dump | |
26 | (after calling clean_up, but before calling userexit). | |
27 | */ | |
28 | ||
29 | ||
30 | char *Mesg[NSIG] { | |
31 | 0, | |
32 | 0, /* Hangup */ | |
33 | 0, /* Interrupt */ | |
34 | 0, /* Quit */ | |
35 | # ifdef PWB | |
36 | "Illegal instruction", | |
37 | "Trace/BPT trap", | |
38 | "IOT trap", | |
39 | "EMT trap", | |
40 | "Floating exception", | |
41 | "Killed", | |
42 | "Bus error", | |
43 | "Memory fault", | |
44 | "Bad system call", | |
45 | "Broken pipe", | |
46 | "Alarm clock", | |
47 | "Terminated" | |
48 | # endif PWB | |
49 | }; | |
50 | ||
51 | ||
52 | setsig() | |
53 | { | |
54 | extern int setsig1(); | |
55 | register int j, n; | |
56 | ||
57 | for (j=1; j<NSIG; j++) | |
58 | if (n=signal(j,setsig1)) | |
59 | signal(j,n); | |
60 | } | |
61 | ||
62 | ||
63 | static char preface[] "SIGNAL: "; | |
64 | static char endmsg[] " (ut12)\n"; | |
65 | ||
66 | setsig1(sig) | |
67 | int sig; | |
68 | { | |
69 | # ifndef PWB | |
70 | sig = 2; | |
71 | # endif PWB | |
72 | if (Mesg[sig]) { | |
73 | syswrite(2,preface,length(preface)); | |
74 | syswrite(2,Mesg[sig],length(Mesg[sig])); | |
75 | syswrite(2,endmsg,length(endmsg)); | |
76 | } | |
77 | else | |
78 | signal(sig,1); | |
79 | clean_up(sig); | |
80 | if(open("dump.core",0) > 0) { | |
81 | signal(SIGIOT,0); | |
82 | abort(); | |
83 | } | |
84 | exit(userexit(1)); | |
85 | } |