3547
|
1 /* |
|
2 |
|
3 Copyright (C) 2000 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3547
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
3579
|
28 #include <signal.h> |
|
29 |
3547
|
30 #include "siglist.h" |
|
31 |
5844
|
32 /* The following is all borrowed from Emacs. */ |
|
33 |
|
34 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST) |
|
35 |
|
36 static char *my_sys_siglist[NSIG]; |
|
37 |
|
38 #ifdef sys_siglist |
|
39 #undef sys_siglist |
|
40 #endif |
|
41 #define sys_siglist my_sys_siglist |
|
42 |
|
43 #endif |
|
44 |
|
45 void |
|
46 init_signals (void) |
3547
|
47 { |
5844
|
48 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST) |
|
49 |
|
50 static int initialized = 0; |
|
51 |
|
52 if (! initialized) |
|
53 { |
|
54 initialized = 1; |
|
55 |
|
56 # ifdef SIGABRT |
|
57 sys_siglist[SIGABRT] = "Aborted"; |
|
58 # endif |
|
59 # ifdef SIGAIO |
|
60 sys_siglist[SIGAIO] = "LAN I/O interrupt"; |
|
61 # endif |
|
62 # ifdef SIGALRM |
|
63 sys_siglist[SIGALRM] = "Alarm clock"; |
|
64 # endif |
|
65 # ifdef SIGBUS |
|
66 sys_siglist[SIGBUS] = "Bus error"; |
|
67 # endif |
|
68 # ifdef SIGCLD |
|
69 sys_siglist[SIGCLD] = "Child status changed"; |
|
70 # endif |
|
71 # ifdef SIGCHLD |
|
72 sys_siglist[SIGCHLD] = "Child status changed"; |
|
73 # endif |
|
74 # ifdef SIGCONT |
|
75 sys_siglist[SIGCONT] = "Continued"; |
|
76 # endif |
|
77 # ifdef SIGDANGER |
|
78 sys_siglist[SIGDANGER] = "Swap space dangerously low"; |
|
79 # endif |
|
80 # ifdef SIGDGNOTIFY |
|
81 sys_siglist[SIGDGNOTIFY] = "Notification message in queue"; |
|
82 # endif |
|
83 # ifdef SIGEMT |
|
84 sys_siglist[SIGEMT] = "Emulation trap"; |
|
85 # endif |
|
86 # ifdef SIGFPE |
|
87 sys_siglist[SIGFPE] = "Arithmetic exception"; |
|
88 # endif |
|
89 # ifdef SIGFREEZE |
|
90 sys_siglist[SIGFREEZE] = "SIGFREEZE"; |
|
91 # endif |
|
92 # ifdef SIGGRANT |
|
93 sys_siglist[SIGGRANT] = "Monitor mode granted"; |
|
94 # endif |
|
95 # ifdef SIGHUP |
|
96 sys_siglist[SIGHUP] = "Hangup"; |
|
97 # endif |
|
98 # ifdef SIGILL |
|
99 sys_siglist[SIGILL] = "Illegal instruction"; |
|
100 # endif |
|
101 # ifdef SIGINT |
|
102 sys_siglist[SIGINT] = "Interrupt"; |
|
103 # endif |
|
104 # ifdef SIGIO |
|
105 sys_siglist[SIGIO] = "I/O possible"; |
|
106 # endif |
|
107 # ifdef SIGIOINT |
|
108 sys_siglist[SIGIOINT] = "I/O intervention required"; |
|
109 # endif |
|
110 # ifdef SIGIOT |
|
111 sys_siglist[SIGIOT] = "IOT trap"; |
|
112 # endif |
|
113 # ifdef SIGKILL |
|
114 sys_siglist[SIGKILL] = "Killed"; |
|
115 # endif |
|
116 # ifdef SIGLOST |
|
117 sys_siglist[SIGLOST] = "Resource lost"; |
|
118 # endif |
|
119 # ifdef SIGLWP |
|
120 sys_siglist[SIGLWP] = "SIGLWP"; |
|
121 # endif |
|
122 # ifdef SIGMSG |
|
123 sys_siglist[SIGMSG] = "Monitor mode data available"; |
|
124 # endif |
|
125 # ifdef SIGPHONE |
|
126 sys_siglist[SIGWIND] = "SIGPHONE"; |
|
127 # endif |
|
128 # ifdef SIGPIPE |
|
129 sys_siglist[SIGPIPE] = "Broken pipe"; |
|
130 # endif |
|
131 # ifdef SIGPOLL |
|
132 sys_siglist[SIGPOLL] = "Pollable event occurred"; |
|
133 # endif |
|
134 # ifdef SIGPROF |
|
135 sys_siglist[SIGPROF] = "Profiling timer expired"; |
|
136 # endif |
|
137 # ifdef SIGPTY |
|
138 sys_siglist[SIGPTY] = "PTY I/O interrupt"; |
|
139 # endif |
|
140 # ifdef SIGPWR |
|
141 sys_siglist[SIGPWR] = "Power-fail restart"; |
|
142 # endif |
|
143 # ifdef SIGQUIT |
|
144 sys_siglist[SIGQUIT] = "Quit"; |
|
145 # endif |
|
146 # ifdef SIGRETRACT |
|
147 sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode"; |
|
148 # endif |
|
149 # ifdef SIGSAK |
|
150 sys_siglist[SIGSAK] = "Secure attention"; |
|
151 # endif |
|
152 # ifdef SIGSEGV |
|
153 sys_siglist[SIGSEGV] = "Segmentation violation"; |
|
154 # endif |
|
155 # ifdef SIGSOUND |
|
156 sys_siglist[SIGSOUND] = "Sound completed"; |
|
157 # endif |
|
158 # ifdef SIGSTOP |
|
159 sys_siglist[SIGSTOP] = "Stopped (signal)"; |
|
160 # endif |
|
161 # ifdef SIGSTP |
|
162 sys_siglist[SIGSTP] = "Stopped (user)"; |
|
163 # endif |
|
164 # ifdef SIGSYS |
|
165 sys_siglist[SIGSYS] = "Bad argument to system call"; |
|
166 # endif |
|
167 # ifdef SIGTERM |
|
168 sys_siglist[SIGTERM] = "Terminated"; |
|
169 # endif |
|
170 # ifdef SIGTHAW |
|
171 sys_siglist[SIGTHAW] = "SIGTHAW"; |
|
172 # endif |
|
173 # ifdef SIGTRAP |
|
174 sys_siglist[SIGTRAP] = "Trace/breakpoint trap"; |
|
175 # endif |
|
176 # ifdef SIGTSTP |
|
177 sys_siglist[SIGTSTP] = "Stopped (user)"; |
|
178 # endif |
|
179 # ifdef SIGTTIN |
|
180 sys_siglist[SIGTTIN] = "Stopped (tty input)"; |
|
181 # endif |
|
182 # ifdef SIGTTOU |
|
183 sys_siglist[SIGTTOU] = "Stopped (tty output)"; |
|
184 # endif |
|
185 # ifdef SIGURG |
|
186 sys_siglist[SIGURG] = "Urgent I/O condition"; |
|
187 # endif |
|
188 # ifdef SIGUSR1 |
|
189 sys_siglist[SIGUSR1] = "User defined signal 1"; |
|
190 # endif |
|
191 # ifdef SIGUSR2 |
|
192 sys_siglist[SIGUSR2] = "User defined signal 2"; |
|
193 # endif |
|
194 # ifdef SIGVTALRM |
|
195 sys_siglist[SIGVTALRM] = "Virtual timer expired"; |
|
196 # endif |
|
197 # ifdef SIGWAITING |
|
198 sys_siglist[SIGWAITING] = "Process's LWPs are blocked"; |
|
199 # endif |
|
200 # ifdef SIGWINCH |
|
201 sys_siglist[SIGWINCH] = "Window size changed"; |
|
202 # endif |
|
203 # ifdef SIGWIND |
|
204 sys_siglist[SIGWIND] = "SIGWIND"; |
|
205 # endif |
|
206 # ifdef SIGXCPU |
|
207 sys_siglist[SIGXCPU] = "CPU time limit exceeded"; |
|
208 # endif |
|
209 # ifdef SIGXFSZ |
|
210 sys_siglist[SIGXFSZ] = "File size limit exceeded"; |
|
211 # endif |
|
212 } |
|
213 |
3547
|
214 #endif |
5844
|
215 } |
|
216 |
|
217 #if ! defined (HAVE_STRSIGNAL) |
|
218 |
|
219 char * |
|
220 strsignal (int code) |
|
221 { |
|
222 char *signame = ""; |
|
223 |
|
224 if (0 <= code && code < NSIG) |
|
225 { |
|
226 /* Cast to suppress warning if the table has const char *. */ |
|
227 signame = (char *) sys_siglist[code]; |
|
228 } |
|
229 |
|
230 return signame; |
|
231 } |
|
232 |
3547
|
233 #endif |
|
234 |
|
235 /* |
|
236 ;;; Local Variables: *** |
5844
|
237 ;;; mode: C *** |
3547
|
238 ;;; End: *** |
|
239 */ |