siglist.c

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2000-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <signal.h>
00028 
00029 #include "siglist.h"
00030 
00031 /* The following is all borrowed from Emacs.  */
00032 
00033 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
00034 
00035 static char *my_sys_siglist[NSIG];
00036 
00037 #ifdef sys_siglist
00038 #undef sys_siglist
00039 #endif
00040 #define sys_siglist my_sys_siglist
00041 
00042 #endif
00043 
00044 void
00045 init_signals (void)
00046 {
00047 #if ! (defined HAVE_STRSIGNAL || HAVE_DECL_SYS_SIGLIST)
00048 
00049   static int initialized = 0;
00050 
00051   if (! initialized)
00052     {
00053       initialized = 1;
00054 
00055 # ifdef SIGABRT
00056       sys_siglist[SIGABRT] = "Aborted";
00057 # endif
00058 # ifdef SIGAIO
00059       sys_siglist[SIGAIO] = "LAN I/O interrupt";
00060 # endif
00061 # ifdef SIGALRM
00062       sys_siglist[SIGALRM] = "Alarm clock";
00063 # endif
00064 # ifdef SIGBUS
00065       sys_siglist[SIGBUS] = "Bus error";
00066 # endif
00067 # ifdef SIGCLD
00068       sys_siglist[SIGCLD] = "Child status changed";
00069 # endif
00070 # ifdef SIGCHLD
00071       sys_siglist[SIGCHLD] = "Child status changed";
00072 # endif
00073 # ifdef SIGCONT
00074       sys_siglist[SIGCONT] = "Continued";
00075 # endif
00076 # ifdef SIGDANGER
00077       sys_siglist[SIGDANGER] = "Swap space dangerously low";
00078 # endif
00079 # ifdef SIGDGNOTIFY
00080       sys_siglist[SIGDGNOTIFY] = "Notification message in queue";
00081 # endif
00082 # ifdef SIGEMT
00083       sys_siglist[SIGEMT] = "Emulation trap";
00084 # endif
00085 # ifdef SIGFPE
00086       sys_siglist[SIGFPE] = "Arithmetic exception";
00087 # endif
00088 # ifdef SIGFREEZE
00089       sys_siglist[SIGFREEZE] = "SIGFREEZE";
00090 # endif
00091 # ifdef SIGGRANT
00092       sys_siglist[SIGGRANT] = "Monitor mode granted";
00093 # endif
00094 # ifdef SIGHUP
00095       sys_siglist[SIGHUP] = "Hangup";
00096 # endif
00097 # ifdef SIGILL
00098       sys_siglist[SIGILL] = "Illegal instruction";
00099 # endif
00100 # ifdef SIGINT
00101       sys_siglist[SIGINT] = "Interrupt";
00102 # endif
00103 # ifdef SIGIO
00104       sys_siglist[SIGIO] = "I/O possible";
00105 # endif
00106 # ifdef SIGIOINT
00107       sys_siglist[SIGIOINT] = "I/O intervention required";
00108 # endif
00109 # ifdef SIGIOT
00110       sys_siglist[SIGIOT] = "IOT trap";
00111 # endif
00112 # ifdef SIGKILL
00113       sys_siglist[SIGKILL] = "Killed";
00114 # endif
00115 # ifdef SIGLOST
00116       sys_siglist[SIGLOST] = "Resource lost";
00117 # endif
00118 # ifdef SIGLWP
00119       sys_siglist[SIGLWP] = "SIGLWP";
00120 # endif
00121 # ifdef SIGMSG
00122       sys_siglist[SIGMSG] = "Monitor mode data available";
00123 # endif
00124 # ifdef SIGPHONE
00125       sys_siglist[SIGWIND] = "SIGPHONE";
00126 # endif
00127 # ifdef SIGPIPE
00128       sys_siglist[SIGPIPE] = "Broken pipe";
00129 # endif
00130 # ifdef SIGPOLL
00131       sys_siglist[SIGPOLL] = "Pollable event occurred";
00132 # endif
00133 # ifdef SIGPROF
00134       sys_siglist[SIGPROF] = "Profiling timer expired";
00135 # endif
00136 # ifdef SIGPTY
00137       sys_siglist[SIGPTY] = "PTY I/O interrupt";
00138 # endif
00139 # ifdef SIGPWR
00140       sys_siglist[SIGPWR] = "Power-fail restart";
00141 # endif
00142 # ifdef SIGQUIT
00143       sys_siglist[SIGQUIT] = "Quit";
00144 # endif
00145 # ifdef SIGRETRACT
00146       sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode";
00147 # endif
00148 # ifdef SIGSAK
00149       sys_siglist[SIGSAK] = "Secure attention";
00150 # endif
00151 # ifdef SIGSEGV
00152       sys_siglist[SIGSEGV] = "Segmentation violation";
00153 # endif
00154 # ifdef SIGSOUND
00155       sys_siglist[SIGSOUND] = "Sound completed";
00156 # endif
00157 # ifdef SIGSTOP
00158       sys_siglist[SIGSTOP] = "Stopped (signal)";
00159 # endif
00160 # ifdef SIGSTP
00161       sys_siglist[SIGSTP] = "Stopped (user)";
00162 # endif
00163 # ifdef SIGSYS
00164       sys_siglist[SIGSYS] = "Bad argument to system call";
00165 # endif
00166 # ifdef SIGTERM
00167       sys_siglist[SIGTERM] = "Terminated";
00168 # endif
00169 # ifdef SIGTHAW
00170       sys_siglist[SIGTHAW] = "SIGTHAW";
00171 # endif
00172 # ifdef SIGTRAP
00173       sys_siglist[SIGTRAP] = "Trace/breakpoint trap";
00174 # endif
00175 # ifdef SIGTSTP
00176       sys_siglist[SIGTSTP] = "Stopped (user)";
00177 # endif
00178 # ifdef SIGTTIN
00179       sys_siglist[SIGTTIN] = "Stopped (tty input)";
00180 # endif
00181 # ifdef SIGTTOU
00182       sys_siglist[SIGTTOU] = "Stopped (tty output)";
00183 # endif
00184 # ifdef SIGURG
00185       sys_siglist[SIGURG] = "Urgent I/O condition";
00186 # endif
00187 # ifdef SIGUSR1
00188       sys_siglist[SIGUSR1] = "User defined signal 1";
00189 # endif
00190 # ifdef SIGUSR2
00191       sys_siglist[SIGUSR2] = "User defined signal 2";
00192 # endif
00193 # ifdef SIGVTALRM
00194       sys_siglist[SIGVTALRM] = "Virtual timer expired";
00195 # endif
00196 # ifdef SIGWAITING
00197       sys_siglist[SIGWAITING] = "Process's LWPs are blocked";
00198 # endif
00199 # ifdef SIGWINCH
00200       sys_siglist[SIGWINCH] = "Window size changed";
00201 # endif
00202 # ifdef SIGWIND
00203       sys_siglist[SIGWIND] = "SIGWIND";
00204 # endif
00205 # ifdef SIGXCPU
00206       sys_siglist[SIGXCPU] = "CPU time limit exceeded";
00207 # endif
00208 # ifdef SIGXFSZ
00209       sys_siglist[SIGXFSZ] = "File size limit exceeded";
00210 # endif
00211     }
00212 
00213 #endif
00214 }
00215 
00216 #if ! defined (HAVE_STRSIGNAL)
00217 
00218 char *
00219 strsignal (int code)
00220 {
00221   char *signame = "";
00222 
00223   if (0 <= code && code < NSIG)
00224     {
00225       /* Cast to suppress warning if the table has const char *.  */
00226       signame = (char *) sys_siglist[code];
00227     }
00228 
00229   return signame;
00230 }
00231 
00232 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines