xref: /freebsd/cddl/lib/libdtrace/signal.d (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  *
22  * Portions Copyright 2008 John Birrell jb@freebsd.org
23  * Portions Copyright 2018 Devin Teske dteske@freebsd.org
24  *
25  * $FreeBSD$
26  */
27 
28 inline int SIGHUP = 1;
29 #pragma D binding "1.0" SIGHUP
30 inline int SIGINT = 2;
31 #pragma D binding "1.0" SIGINT
32 inline int SIGQUIT = 3;
33 #pragma D binding "1.0" SIGQUIT
34 inline int SIGILL = 4;
35 #pragma D binding "1.0" SIGILL
36 inline int SIGTRAP = 5;
37 #pragma D binding "1.0" SIGTRAP
38 inline int SIGABRT = 6;
39 #pragma D binding "1.0" SIGABRT
40 inline int SIGEMT = 7;
41 #pragma D binding "1.0" SIGEMT
42 inline int SIGFPE = 8;
43 #pragma D binding "1.0" SIGFPE
44 inline int SIGKILL = 9;
45 #pragma D binding "1.0" SIGKILL
46 inline int SIGBUS = 10;
47 #pragma D binding "1.0" SIGBUS
48 inline int SIGSEGV = 11;
49 #pragma D binding "1.0" SIGSEGV
50 inline int SIGSYS = 12;
51 #pragma D binding "1.0" SIGSYS
52 inline int SIGPIPE = 13;
53 #pragma D binding "1.0" SIGPIPE
54 inline int SIGALRM = 14;
55 #pragma D binding "1.0" SIGALRM
56 inline int SIGTERM = 15;
57 #pragma D binding "1.0" SIGTERM
58 inline int SIGURG = 16;
59 #pragma D binding "1.0" SIGURG
60 inline int SIGSTOP = 17;
61 #pragma D binding "1.0" SIGSTOP
62 inline int SIGTSTP = 18;
63 #pragma D binding "1.0" SIGTSTP
64 inline int SIGCONT = 19;
65 #pragma D binding "1.0" SIGCONT
66 inline int SIGCHLD = 20;
67 #pragma D binding "1.0" SIGCHLD
68 inline int SIGTTIN = 21;
69 #pragma D binding "1.0" SIGTTIN
70 inline int SIGTTOU = 22;
71 #pragma D binding "1.0" SIGTTOU
72 inline int SIGIO = 23;
73 #pragma D binding "1.0" SIGIO
74 inline int SIGXCPU = 24;
75 #pragma D binding "1.0" SIGXCPU
76 inline int SIGXFSZ = 25;
77 #pragma D binding "1.0" SIGXFSZ
78 inline int SIGVTALRM = 26;
79 #pragma D binding "1.0" SIGVTALRM
80 inline int SIGPROF = 27;
81 #pragma D binding "1.0" SIGPROF
82 inline int SIGWINCH = 28;
83 #pragma D binding "1.0" SIGWINCH
84 inline int SIGINFO = 29;
85 #pragma D binding "1.0" SIGINFO
86 inline int SIGUSR1 = 30;
87 #pragma D binding "1.0" SIGUSR1
88 inline int SIGUSR2 = 31;
89 #pragma D binding "1.0" SIGUSR2
90 inline int SIGTHR = 32;
91 #pragma D binding "1.13" SIGTHR
92 inline int SIGLIBRT = 33;
93 #pragma D binding "1.13" SIGLIBRT
94 
95 #pragma D binding "1.13" signal_string
96 inline string signal_string[int signal] =
97 	signal == SIGHUP ?	"SIGHUP" :
98 	signal == SIGINT ?	"SIGINT" :
99 	signal == SIGQUIT ?	"SIGQUIT" :
100 	signal == SIGILL ?	"SIGILL":
101 	signal == SIGTRAP ?	"SIGTRAP" :
102 	signal == SIGABRT ?	"SIGABRT" :
103 	signal == SIGEMT ?	"SIGEMT" :
104 	signal == SIGFPE ?	"SIGFPE" :
105 	signal == SIGKILL ?	"SIGKILL" :
106 	signal == SIGBUS ?	"SIGBUS" :
107 	signal == SIGSEGV ?	"SIGSEGV" :
108 	signal == SIGSYS ?	"SIGSYS" :
109 	signal == SIGPIPE ?	"SIGPIPE" :
110 	signal == SIGALRM ?	"SIGALRM" :
111 	signal == SIGTERM ?	"SIGTERM" :
112 	signal == SIGURG ?	"SIGURG" :
113 	signal == SIGSTOP ?	"SIGSTOP" :
114 	signal == SIGTSTP ?	"SIGTSTP" :
115 	signal == SIGCONT ?	"SIGCONT" :
116 	signal == SIGCHLD ?	"SIGCHLD" :
117 	signal == SIGTTIN ?	"SIGTTIN" :
118 	signal == SIGTTOU ?	"SIGTTOU" :
119 	signal == SIGIO ?	"SIGIO" :
120 	signal == SIGXCPU ?	"SIGXCPU" :
121 	signal == SIGXFSZ ?	"SIGXFSZ" :
122 	signal == SIGVTALRM ?	"SIGVTALRM" :
123 	signal == SIGPROF ?	"SIGPROF" :
124 	signal == SIGWINCH ?	"SIGWINCH" :
125 	signal == SIGINFO ?	"SIGINFO" :
126 	signal == SIGUSR1 ?	"SIGUSR1" :
127 	signal == SIGUSR2 ?	"SIGUSR2" :
128 	signal == SIGTHR ?	"SIGTHR" :
129 	signal == SIGLIBRT ?	"SIGLIBRT" :
130 	"UNKNOWN";
131 
132 inline int CLD_EXITED = 1;
133 #pragma D binding "1.0" CLD_EXITED
134 inline int CLD_KILLED = 2;
135 #pragma D binding "1.0" CLD_KILLED
136 inline int CLD_DUMPED = 3;
137 #pragma D binding "1.0" CLD_DUMPED
138 inline int CLD_TRAPPED = 4;
139 #pragma D binding "1.0" CLD_TRAPPED
140 inline int CLD_STOPPED = 5;
141 #pragma D binding "1.0" CLD_STOPPED
142 inline int CLD_CONTINUED = 6;
143 #pragma D binding "1.0" CLD_CONTINUED
144 
145 #pragma D binding "1.13" child_signal_string
146 inline string child_signal_string[int child_signal] =
147 	child_signal == CLD_EXITED ?	"child exited" :
148 	child_signal == CLD_KILLED ?	"child terminated abnormally" :
149 	child_signal == CLD_DUMPED ?	"child core dumped" :
150 	child_signal == CLD_TRAPPED ?	"traced child trapped" :
151 	child_signal == CLD_STOPPED ?	"child stopped" :
152 	child_signal == CLD_CONTINUED ?	"stopped child continued" :
153 	strjoin("unknown SIGCHLD code (", strjoin(lltostr(child_signal), ")"));
154