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
| | #include <signal.h>
#include <string.h>
int sig2str(int sig, char *str)
{
if (sig <= 0) return -1;
if (sig <= SIGSYS)
return (strcpy(str, __sys_signame[sig]), 0);
if (sig == SIGRTMIN)
return (strcpy(str, "RTMIN"), 0);
if (sig == SIGRTMAX)
return (strcpy(str, "RTMAX"), 0);
#if SIGPOLL != SIGIO
if (sig == SIGPOLL)
return (strcpy(str, "POLL"), 0);
#endif
if (sig > SIGRTMIN && sig <= SIGRTMAX)
{
strcpy(str, "RTMIN+");
int sigrt = sig-SIGRTMIN;
if (sigrt < 10)
{
str[6] = '0'+sigrt;
str[7] = '\0';
}
else
{
str[6] = '0'+sigrt/10;
str[7] = '0'+sigrt%10;
str[8] = '\0';
}
return 0;
}
return -1;
}
|