GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
siglist.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2000-2013 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <signal.h>
28 
29 #include "siglist.h"
30 
31 /* The following is all borrowed from Emacs. */
32 
33 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
34 
35 static char *my_sys_siglist[NSIG];
36 
37 #ifdef sys_siglist
38 #undef sys_siglist
39 #endif
40 #define sys_siglist my_sys_siglist
41 
42 #endif
43 
44 void
46 {
47 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
48 
49  static int initialized = 0;
50 
51  if (! initialized)
52  {
53  initialized = 1;
54 
55 # ifdef SIGABRT
56  sys_siglist[SIGABRT] = "Aborted";
57 # endif
58 # ifdef SIGAIO
59  sys_siglist[SIGAIO] = "LAN I/O interrupt";
60 # endif
61 # ifdef SIGALRM
62  sys_siglist[SIGALRM] = "Alarm clock";
63 # endif
64 # ifdef SIGBUS
65  sys_siglist[SIGBUS] = "Bus error";
66 # endif
67 # ifdef SIGCLD
68  sys_siglist[SIGCLD] = "Child status changed";
69 # endif
70 # ifdef SIGCHLD
71  sys_siglist[SIGCHLD] = "Child status changed";
72 # endif
73 # ifdef SIGCONT
74  sys_siglist[SIGCONT] = "Continued";
75 # endif
76 # ifdef SIGDANGER
77  sys_siglist[SIGDANGER] = "Swap space dangerously low";
78 # endif
79 # ifdef SIGDGNOTIFY
80  sys_siglist[SIGDGNOTIFY] = "Notification message in queue";
81 # endif
82 # ifdef SIGEMT
83  sys_siglist[SIGEMT] = "Emulation trap";
84 # endif
85 # ifdef SIGFPE
86  sys_siglist[SIGFPE] = "Arithmetic exception";
87 # endif
88 # ifdef SIGFREEZE
89  sys_siglist[SIGFREEZE] = "SIGFREEZE";
90 # endif
91 # ifdef SIGGRANT
92  sys_siglist[SIGGRANT] = "Monitor mode granted";
93 # endif
94 # ifdef SIGHUP
95  sys_siglist[SIGHUP] = "Hangup";
96 # endif
97 # ifdef SIGILL
98  sys_siglist[SIGILL] = "Illegal instruction";
99 # endif
100 # ifdef SIGINT
101  sys_siglist[SIGINT] = "Interrupt";
102 # endif
103 # ifdef SIGIO
104  sys_siglist[SIGIO] = "I/O possible";
105 # endif
106 # ifdef SIGIOINT
107  sys_siglist[SIGIOINT] = "I/O intervention required";
108 # endif
109 # ifdef SIGIOT
110  sys_siglist[SIGIOT] = "IOT trap";
111 # endif
112 # ifdef SIGKILL
113  sys_siglist[SIGKILL] = "Killed";
114 # endif
115 # ifdef SIGLOST
116  sys_siglist[SIGLOST] = "Resource lost";
117 # endif
118 # ifdef SIGLWP
119  sys_siglist[SIGLWP] = "SIGLWP";
120 # endif
121 # ifdef SIGMSG
122  sys_siglist[SIGMSG] = "Monitor mode data available";
123 # endif
124 # ifdef SIGPHONE
125  sys_siglist[SIGPHONE] = "SIGPHONE";
126 # endif
127 # ifdef SIGPIPE
128  sys_siglist[SIGPIPE] = "Broken pipe";
129 # endif
130 # ifdef SIGPOLL
131  sys_siglist[SIGPOLL] = "Pollable event occurred";
132 # endif
133 # ifdef SIGPROF
134  sys_siglist[SIGPROF] = "Profiling timer expired";
135 # endif
136 # ifdef SIGPTY
137  sys_siglist[SIGPTY] = "PTY I/O interrupt";
138 # endif
139 # ifdef SIGPWR
140  sys_siglist[SIGPWR] = "Power-fail restart";
141 # endif
142 # ifdef SIGQUIT
143  sys_siglist[SIGQUIT] = "Quit";
144 # endif
145 # ifdef SIGRETRACT
146  sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode";
147 # endif
148 # ifdef SIGSAK
149  sys_siglist[SIGSAK] = "Secure attention";
150 # endif
151 # ifdef SIGSEGV
152  sys_siglist[SIGSEGV] = "Segmentation violation";
153 # endif
154 # ifdef SIGSOUND
155  sys_siglist[SIGSOUND] = "Sound completed";
156 # endif
157 # ifdef SIGSTKFLT
158  sys_siglist[SIGSTKFLT] = "Stack fault";
159 # endif
160 # ifdef SIGSTOP
161  sys_siglist[SIGSTOP] = "Stopped (signal)";
162 # endif
163 # ifdef SIGSTP
164  sys_siglist[SIGSTP] = "Stopped (user)";
165 # endif
166 # ifdef SIGSYS
167  sys_siglist[SIGSYS] = "Bad argument to system call";
168 # endif
169 # ifdef SIGTERM
170  sys_siglist[SIGTERM] = "Terminated";
171 # endif
172 # ifdef SIGTHAW
173  sys_siglist[SIGTHAW] = "SIGTHAW";
174 # endif
175 # ifdef SIGTRAP
176  sys_siglist[SIGTRAP] = "Trace/breakpoint trap";
177 # endif
178 # ifdef SIGTSTP
179  sys_siglist[SIGTSTP] = "Stopped (user)";
180 # endif
181 # ifdef SIGTTIN
182  sys_siglist[SIGTTIN] = "Stopped (tty input)";
183 # endif
184 # ifdef SIGTTOU
185  sys_siglist[SIGTTOU] = "Stopped (tty output)";
186 # endif
187 # ifdef SIGUNUSED
188  sys_siglist[SIGUNUSED] = "SIGUNUSED";
189 # endif
190 # ifdef SIGURG
191  sys_siglist[SIGURG] = "Urgent I/O condition";
192 # endif
193 # ifdef SIGUSR1
194  sys_siglist[SIGUSR1] = "User defined signal 1";
195 # endif
196 # ifdef SIGUSR2
197  sys_siglist[SIGUSR2] = "User defined signal 2";
198 # endif
199 # ifdef SIGVTALRM
200  sys_siglist[SIGVTALRM] = "Virtual timer expired";
201 # endif
202 # ifdef SIGWAITING
203  sys_siglist[SIGWAITING] = "Process's LWPs are blocked";
204 # endif
205 # ifdef SIGWINCH
206  sys_siglist[SIGWINCH] = "Window size changed";
207 # endif
208 # ifdef SIGWIND
209  sys_siglist[SIGWIND] = "SIGWIND";
210 # endif
211 # ifdef SIGXCPU
212  sys_siglist[SIGXCPU] = "CPU time limit exceeded";
213 # endif
214 # ifdef SIGXFSZ
215  sys_siglist[SIGXFSZ] = "File size limit exceeded";
216 # endif
217  }
218 
219 #endif
220 }
221 
222 #if ! defined (HAVE_STRSIGNAL)
223 
224 char *
225 strsignal (int code)
226 {
227  char *signame = "";
228 
229  if (0 <= code && code < NSIG)
230  {
231  /* Cast to suppress warning if the table has const char *. */
232  signame = (char *) sys_siglist[code];
233  }
234 
235  return signame;
236 }
237 
238 #endif