forked from MeiK2333/apue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2.c
56 lines (53 loc) · 1.32 KB
/
p2.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
51
52
53
54
55
56
#include <signal.h>
#include <stdio.h>
#include <string.h>
#define s2s(signo, str, signal) \
{ \
if (signo == signal) strcpy(str, #signal); \
}
void sig2str(int signo, char *str) {
strcpy(str, "UNKNOWN");
s2s(signo, str, SIGKILL);
s2s(signo, str, SIGHUP);
s2s(signo, str, SIGINT);
s2s(signo, str, SIGQUIT);
s2s(signo, str, SIGILL);
s2s(signo, str, SIGTRAP);
s2s(signo, str, SIGABRT);
s2s(signo, str, SIGIOT);
s2s(signo, str, SIGBUS);
s2s(signo, str, SIGFPE);
s2s(signo, str, SIGKILL);
s2s(signo, str, SIGUSR1);
s2s(signo, str, SIGSEGV);
s2s(signo, str, SIGUSR2);
s2s(signo, str, SIGPIPE);
s2s(signo, str, SIGALRM);
s2s(signo, str, SIGTERM);
s2s(signo, str, SIGSTKFLT);
s2s(signo, str, SIGCHLD);
s2s(signo, str, SIGCONT);
s2s(signo, str, SIGSTOP);
s2s(signo, str, SIGTSTP);
s2s(signo, str, SIGTTIN);
s2s(signo, str, SIGTTOU);
s2s(signo, str, SIGURG);
s2s(signo, str, SIGXCPU);
s2s(signo, str, SIGXFSZ);
s2s(signo, str, SIGVTALRM);
s2s(signo, str, SIGPROF);
s2s(signo, str, SIGWINCH);
s2s(signo, str, SIGIO);
s2s(signo, str, SIGPWR);
s2s(signo, str, SIGSYS);
s2s(signo, str, SIGRTMIN);
}
int main() {
int n;
char str[1024];
while (1) {
scanf("%d", &n);
sig2str(n, str);
printf("%s\n", str);
}
}