-
Notifications
You must be signed in to change notification settings - Fork 1
/
signals.c
50 lines (48 loc) · 1.51 KB
/
signals.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <signal.h>
#include <sys/wait.h>
#include "topline.h"
static const char* sigobits[NSIG]=
{
[SIGHUP] = "Hangup",
[SIGINT] = "Interrupt",
[SIGQUIT] = "Quit",
[SIGILL] = "Illegal instruction",
[SIGTRAP] = "Breakpoint trap",
[SIGABRT] = "Aborted",
[SIGBUS] = "Bus error",
[SIGFPE] = "Floating point exception",
[SIGKILL] = "Killed",
[SIGUSR1] = "User signal 1",
[SIGSEGV] = "Segmentation fault",
[SIGUSR2] = "User signal 2",
[SIGPIPE] = "Broken pipe",
[SIGALRM] = "Alarm clock",
[SIGTERM] = "Terminated",
#ifdef SIGSTKFLT
[SIGSTKFLT] = "Stack fault on coprocessor",
#endif
[SIGCHLD] = "Child died",
[SIGCONT] = "Continue",
[SIGSTOP] = "Stopped",
[SIGTSTP] = "Stop request on terminal",
[SIGTTIN] = "Stopped on tty input",
[SIGTTOU] = "Stopped on tty output",
[SIGURG] = "Urgent condition on socket",
[SIGXCPU] = "CPU limit exceeded",
[SIGXFSZ] = "File size limit exceeded",
[SIGVTALRM] = "Virtual alarm clock",
[SIGPROF] = "Profiler timer expired",
[SIGWINCH] = "Window size changed",
[SIGIO] = "I/O ready",
[SIGPWR] = "Power loss",
[SIGSYS] = "Bad system call",
};
void sigobit(int ret)
{
int core = WCOREDUMP(ret);
int s = WTERMSIG(ret);
if (s>0 && s<NSIG && sigobits[s])
fprintf(stderr, "%s%s\n", sigobits[s], core?" (core dumped)":"");
else
fprintf(stderr, "Died to signal %d%s\n", s, core?" (core dumped)":"");
}