1 /*
2  * Copyright (c) 2014 Fujitsu Ltd.
3  * Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
tst_strsig(int sig)18 const char *tst_strsig(int sig)
19 {
20 	static const struct pair signal_pairs[] = {
21 		PAIR(SIGHUP)
22 		PAIR(SIGINT)
23 		PAIR(SIGQUIT)
24 		PAIR(SIGILL)
25 	#ifdef SIGTRAP
26 		PAIR(SIGTRAP)
27 	#endif
28 
29 	#ifdef SIGIOT
30 		/* SIGIOT same as SIGABRT */
31 		STRPAIR(SIGABRT, "SIGIOT/SIGABRT")
32 	#else
33 		PAIR(SIGABRT)
34 	#endif
35 
36 	#ifdef SIGEMT
37 		PAIR(SIGEMT)
38 	#endif
39 	#ifdef SIGBUS
40 		PAIR(SIGBUS)
41 	#endif
42 		PAIR(SIGFPE)
43 		PAIR(SIGKILL)
44 		PAIR(SIGUSR1)
45 		PAIR(SIGSEGV)
46 		PAIR(SIGUSR2)
47 		PAIR(SIGPIPE)
48 		PAIR(SIGALRM)
49 		PAIR(SIGTERM)
50 	#ifdef SIGSTKFLT
51 		PAIR(SIGSTKFLT)
52 	#endif
53 
54 	#ifdef SIGCLD
55 		/* SIGCLD same as SIGCHLD */
56 		STRPAIR(SIGCHLD, "SIGCHLD/SIGCLD")
57 	#else
58 		PAIR(SIGCHLD)
59 	#endif
60 		PAIR(SIGCONT)
61 		PAIR(SIGSTOP)
62 		PAIR(SIGTSTP)
63 		PAIR(SIGTTIN)
64 		PAIR(SIGTTOU)
65 	#ifdef SIGURG
66 		PAIR(SIGURG)
67 	#endif
68 	#ifdef SIGXCPU
69 		PAIR(SIGXCPU)
70 	#endif
71 	#ifdef SIGXFSZ
72 		PAIR(SIGXFSZ)
73 	#endif
74 	#ifdef SIGVTALRM
75 		PAIR(SIGVTALRM)
76 	#endif
77 	#ifdef SIGPROF
78 		PAIR(SIGPROF)
79 	#endif
80 	#ifdef SIGWINCH
81 		PAIR(SIGWINCH)
82 	#endif
83 
84 	#if defined(SIGIO) && defined(SIGPOLL)
85 		/* SIGPOLL same as SIGIO */
86 		STRPAIR(SIGIO, "SIGIO/SIGPOLL")
87 	#elif defined(SIGIO)
88 		PAIR(SIGIO)
89 	#elif defined(SIGPOLL)
90 		PAIR(SIGPOLL)
91 	#endif
92 
93 	#ifdef SIGINFO
94 		PAIR(SIGINFO)
95 	#endif
96 	#ifdef SIGLOST
97 		PAIR(SIGLOST)
98 	#endif
99 	#ifdef SIGPWR
100 		PAIR(SIGPWR)
101 	#endif
102 	#if defined(SIGSYS)
103 		/*
104 		 * According to signal(7)'s manpage, SIGUNUSED is synonymous
105 		 * with SIGSYS on most architectures.
106 		 */
107 		STRPAIR(SIGSYS, "SIGSYS/SIGUNUSED")
108 	#endif
109 	};
110 
111 	PAIR_LOOKUP(signal_pairs, sig);
112 };
113