| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#include "make.h" |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
#if !HAVE_STRSIGNAL |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
#if !HAVE_DECL_SYS_SIGLIST |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
#ifndef NSIG |
|---|
| 32 |
#ifdef _NSIG |
|---|
| 33 |
#define NSIG _NSIG |
|---|
| 34 |
#else |
|---|
| 35 |
#define NSIG 32 |
|---|
| 36 |
#endif |
|---|
| 37 |
#endif |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
static const char *undoc; |
|---|
| 43 |
|
|---|
| 44 |
static const char *sys_siglist[NSIG]; |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#define SIG_TABLE_SIZE (NSIG*2) |
|---|
| 49 |
|
|---|
| 50 |
typedef struct |
|---|
| 51 |
{ |
|---|
| 52 |
int number; |
|---|
| 53 |
const char *abbrev; |
|---|
| 54 |
} num_abbrev; |
|---|
| 55 |
|
|---|
| 56 |
static num_abbrev sig_table[SIG_TABLE_SIZE]; |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
static int sig_table_nelts = 0; |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
static void |
|---|
| 64 |
init_sig (int number, const char *abbrev, const char *name) |
|---|
| 65 |
{ |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
if (number >= 0 && number < NSIG) |
|---|
| 71 |
sys_siglist[number] = name; |
|---|
| 72 |
|
|---|
| 73 |
if (sig_table_nelts < SIG_TABLE_SIZE) |
|---|
| 74 |
{ |
|---|
| 75 |
sig_table[sig_table_nelts].number = number; |
|---|
| 76 |
sig_table[sig_table_nelts++].abbrev = abbrev; |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
static int |
|---|
| 81 |
signame_init (void) |
|---|
| 82 |
{ |
|---|
| 83 |
int i; |
|---|
| 84 |
|
|---|
| 85 |
undoc = xstrdup (_("unknown signal")); |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
for (i = 0; i < NSIG; i++) |
|---|
| 89 |
sys_siglist[i] = undoc; |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
#if defined (SIGHUP) |
|---|
| 93 |
init_sig (SIGHUP, "HUP", _("Hangup")); |
|---|
| 94 |
#endif |
|---|
| 95 |
#if defined (SIGINT) |
|---|
| 96 |
init_sig (SIGINT, "INT", _("Interrupt")); |
|---|
| 97 |
#endif |
|---|
| 98 |
#if defined (SIGQUIT) |
|---|
| 99 |
init_sig (SIGQUIT, "QUIT", _("Quit")); |
|---|
| 100 |
#endif |
|---|
| 101 |
#if defined (SIGILL) |
|---|
| 102 |
init_sig (SIGILL, "ILL", _("Illegal Instruction")); |
|---|
| 103 |
#endif |
|---|
| 104 |
#if defined (SIGTRAP) |
|---|
| 105 |
init_sig (SIGTRAP, "TRAP", _("Trace/breakpoint trap")); |
|---|
| 106 |
#endif |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
#if defined (SIGABRT) |
|---|
| 110 |
init_sig (SIGABRT, "ABRT", _("Aborted")); |
|---|
| 111 |
#endif |
|---|
| 112 |
#if defined (SIGIOT) |
|---|
| 113 |
init_sig (SIGIOT, "IOT", _("IOT trap")); |
|---|
| 114 |
#endif |
|---|
| 115 |
#if defined (SIGEMT) |
|---|
| 116 |
init_sig (SIGEMT, "EMT", _("EMT trap")); |
|---|
| 117 |
#endif |
|---|
| 118 |
#if defined (SIGFPE) |
|---|
| 119 |
init_sig (SIGFPE, "FPE", _("Floating point exception")); |
|---|
| 120 |
#endif |
|---|
| 121 |
#if defined (SIGKILL) |
|---|
| 122 |
init_sig (SIGKILL, "KILL", _("Killed")); |
|---|
| 123 |
#endif |
|---|
| 124 |
#if defined (SIGBUS) |
|---|
| 125 |
init_sig (SIGBUS, "BUS", _("Bus error")); |
|---|
| 126 |
#endif |
|---|
| 127 |
#if defined (SIGSEGV) |
|---|
| 128 |
init_sig (SIGSEGV, "SEGV", _("Segmentation fault")); |
|---|
| 129 |
#endif |
|---|
| 130 |
#if defined (SIGSYS) |
|---|
| 131 |
init_sig (SIGSYS, "SYS", _("Bad system call")); |
|---|
| 132 |
#endif |
|---|
| 133 |
#if defined (SIGPIPE) |
|---|
| 134 |
init_sig (SIGPIPE, "PIPE", _("Broken pipe")); |
|---|
| 135 |
#endif |
|---|
| 136 |
#if defined (SIGALRM) |
|---|
| 137 |
init_sig (SIGALRM, "ALRM", _("Alarm clock")); |
|---|
| 138 |
#endif |
|---|
| 139 |
#if defined (SIGTERM) |
|---|
| 140 |
init_sig (SIGTERM, "TERM", _("Terminated")); |
|---|
| 141 |
#endif |
|---|
| 142 |
#if defined (SIGUSR1) |
|---|
| 143 |
init_sig (SIGUSR1, "USR1", _("User defined signal 1")); |
|---|
| 144 |
#endif |
|---|
| 145 |
#if defined (SIGUSR2) |
|---|
| 146 |
init_sig (SIGUSR2, "USR2", _("User defined signal 2")); |
|---|
| 147 |
#endif |
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
#if defined (SIGCHLD) |
|---|
| 151 |
init_sig (SIGCHLD, "CHLD", _("Child exited")); |
|---|
| 152 |
#endif |
|---|
| 153 |
#if defined (SIGCLD) |
|---|
| 154 |
init_sig (SIGCLD, "CLD", _("Child exited")); |
|---|
| 155 |
#endif |
|---|
| 156 |
#if defined (SIGPWR) |
|---|
| 157 |
init_sig (SIGPWR, "PWR", _("Power failure")); |
|---|
| 158 |
#endif |
|---|
| 159 |
#if defined (SIGTSTP) |
|---|
| 160 |
init_sig (SIGTSTP, "TSTP", _("Stopped")); |
|---|
| 161 |
#endif |
|---|
| 162 |
#if defined (SIGTTIN) |
|---|
| 163 |
init_sig (SIGTTIN, "TTIN", _("Stopped (tty input)")); |
|---|
| 164 |
#endif |
|---|
| 165 |
#if defined (SIGTTOU) |
|---|
| 166 |
init_sig (SIGTTOU, "TTOU", _("Stopped (tty output)")); |
|---|
| 167 |
#endif |
|---|
| 168 |
#if defined (SIGSTOP) |
|---|
| 169 |
init_sig (SIGSTOP, "STOP", _("Stopped (signal)")); |
|---|
| 170 |
#endif |
|---|
| 171 |
#if defined (SIGXCPU) |
|---|
| 172 |
init_sig (SIGXCPU, "XCPU", _("CPU time limit exceeded")); |
|---|
| 173 |
#endif |
|---|
| 174 |
#if defined (SIGXFSZ) |
|---|
| 175 |
init_sig (SIGXFSZ, "XFSZ", _("File size limit exceeded")); |
|---|
| 176 |
#endif |
|---|
| 177 |
#if defined (SIGVTALRM) |
|---|
| 178 |
init_sig (SIGVTALRM, "VTALRM", _("Virtual timer expired")); |
|---|
| 179 |
#endif |
|---|
| 180 |
#if defined (SIGPROF) |
|---|
| 181 |
init_sig (SIGPROF, "PROF", _("Profiling timer expired")); |
|---|
| 182 |
#endif |
|---|
| 183 |
#if defined (SIGWINCH) |
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
init_sig (SIGWINCH, "WINCH", _("Window changed")); |
|---|
| 188 |
#endif |
|---|
| 189 |
#if defined (SIGCONT) |
|---|
| 190 |
init_sig (SIGCONT, "CONT", _("Continued")); |
|---|
| 191 |
#endif |
|---|
| 192 |
#if defined (SIGURG) |
|---|
| 193 |
init_sig (SIGURG, "URG", _("Urgent I/O condition")); |
|---|
| 194 |
#endif |
|---|
| 195 |
#if defined (SIGIO) |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
init_sig (SIGIO, "IO", _("I/O possible")); |
|---|
| 201 |
#endif |
|---|
| 202 |
#if defined (SIGWIND) |
|---|
| 203 |
init_sig (SIGWIND, "WIND", _("SIGWIND")); |
|---|
| 204 |
#endif |
|---|
| 205 |
#if defined (SIGPHONE) |
|---|
| 206 |
init_sig (SIGPHONE, "PHONE", _("SIGPHONE")); |
|---|
| 207 |
#endif |
|---|
| 208 |
#if defined (SIGPOLL) |
|---|
| 209 |
init_sig (SIGPOLL, "POLL", _("I/O possible")); |
|---|
| 210 |
#endif |
|---|
| 211 |
#if defined (SIGLOST) |
|---|
| 212 |
init_sig (SIGLOST, "LOST", _("Resource lost")); |
|---|
| 213 |
#endif |
|---|
| 214 |
#if defined (SIGDANGER) |
|---|
| 215 |
init_sig (SIGDANGER, "DANGER", _("Danger signal")); |
|---|
| 216 |
#endif |
|---|
| 217 |
#if defined (SIGINFO) |
|---|
| 218 |
init_sig (SIGINFO, "INFO", _("Information request")); |
|---|
| 219 |
#endif |
|---|
| 220 |
#if defined (SIGNOFP) |
|---|
| 221 |
init_sig (SIGNOFP, "NOFP", _("Floating point co-processor not available")); |
|---|
| 222 |
#endif |
|---|
| 223 |
|
|---|
| 224 |
return 1; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
#endif |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
char * |
|---|
| 231 |
strsignal (int signal) |
|---|
| 232 |
{ |
|---|
| 233 |
static char buf[] = "Signal 12345678901234567890"; |
|---|
| 234 |
|
|---|
| 235 |
#if ! HAVE_DECL_SYS_SIGLIST |
|---|
| 236 |
# if HAVE_DECL__SYS_SIGLIST |
|---|
| 237 |
# define sys_siglist _sys_siglist |
|---|
| 238 |
# elif HAVE_DECL___SYS_SIGLIST |
|---|
| 239 |
# define sys_siglist __sys_siglist |
|---|
| 240 |
# else |
|---|
| 241 |
static char sig_initted = 0; |
|---|
| 242 |
|
|---|
| 243 |
if (!sig_initted) |
|---|
| 244 |
sig_initted = signame_init (); |
|---|
| 245 |
# endif |
|---|
| 246 |
#endif |
|---|
| 247 |
|
|---|
| 248 |
if (signal > 0 || signal < NSIG) |
|---|
| 249 |
return (char *) sys_siglist[signal]; |
|---|
| 250 |
|
|---|
| 251 |
sprintf (buf, "Signal %d", signal); |
|---|
| 252 |
return buf; |
|---|
| 253 |
} |
|---|
| 254 |
|
|---|
| 255 |
#endif |
|---|