2 * sigstat - print out useful information about signal arguments
8 /* Copyright (C) 1991-2002 Free Software Foundation, Inc.
10 This file is part of GNU Bash, the Bourne Again SHell.
12 Bash is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free
14 Software Foundation; either version 2, or (at your option) any later
17 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
18 WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 You should have received a copy of the GNU General Public License along
23 with Bash; see the file COPYING. If not, write to the Free Software
24 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
26 #include <sys/types.h>
30 extern char *strrchr();
31 static char *signames
[NSIG
];
44 if (t
= strrchr(argv
[0], '/'))
50 for (i
= 1; i
< NSIG
; i
++)
54 for (i
= 1; i
< argc
; i
++)
55 sigstat(atoi(argv
[i
]));
63 struct sigaction oact
;
68 if (sig
< 0 || sig
>= NSIG
) {
69 fprintf(stderr
, "%s: %d: signal out of range\n", progname
, sig
);
72 signame
= signames
[sig
];
74 sigprocmask(SIG_BLOCK
, (sigset_t
*)NULL
, &oset
);
75 if (sigismember(&oset
, sig
))
76 printf("%s: signal is blocked\n", signame
);
77 sigaction(sig
, (struct sigaction
*)NULL
, &oact
);
78 if (oact
.sa_handler
== SIG_IGN
)
79 printf("%s: signal is ignored\n", signame
);
80 else if (oact
.sa_handler
== SIG_DFL
)
81 printf("%s: signal is defaulted\n", signame
);
83 printf("%s: signal is trapped (?)\n", signame
);
89 bzero(signames
, sizeof(signames
));
91 #if defined (SIGHUP) /* hangup */
92 signames
[SIGHUP
] = "SIGHUP";
94 #if defined (SIGINT) /* interrupt */
95 signames
[SIGINT
] = "SIGINT";
97 #if defined (SIGQUIT) /* quit */
98 signames
[SIGQUIT
] = "SIGQUIT";
100 #if defined (SIGILL) /* illegal instruction (not reset when caught) */
101 signames
[SIGILL
] = "SIGILL";
103 #if defined (SIGTRAP) /* trace trap (not reset when caught) */
104 signames
[SIGTRAP
] = "SIGTRAP";
106 #if defined (SIGABRT) /* */
107 signames
[SIGABRT
] = "SIGABRT";
109 #if defined (SIGIOT) /* IOT instruction */
110 signames
[SIGIOT
] = "SIGIOT";
112 #if defined (SIGEMT) /* EMT instruction */
113 signames
[SIGEMT
] = "SIGEMT";
115 #if defined (SIGFPE) /* floating point exception */
116 signames
[SIGFPE
] = "SIGFPE";
118 #if defined (SIGKILL) /* kill (cannot be caught or ignored) */
119 signames
[SIGKILL
] = "SIGKILL";
121 #if defined (SIGBUS) /* bus error */
122 signames
[SIGBUS
] = "SIGBUS";
124 #if defined (SIGSEGV) /* segmentation violation */
125 signames
[SIGSEGV
] = "SIGSEGV";
127 #if defined (SIGSYS) /* bad argument to system call */
128 signames
[SIGSYS
] = "SIGSYS";
130 #if defined (SIGPIPE) /* write on a pipe with no one to read it */
131 signames
[SIGPIPE
] = "SIGPIPE";
133 #if defined (SIGALRM) /* alarm clock */
134 signames
[SIGALRM
] = "SIGALRM";
136 #if defined (SIGTERM) /* software termination signal from kill */
137 signames
[SIGTERM
] = "SIGTERM";
139 #if defined (SIGCLD) /* Like SIGCHLD. */
140 signames
[SIGCLD
] = "SIGCLD";
142 #if defined (SIGPWR) /* Magic thing for some machines. */
143 signames
[SIGPWR
] = "SIGPWR";
145 #if defined (SIGPOLL) /* For keyboard input? */
146 signames
[SIGPOLL
] = "SIGPOLL";
148 #if defined (SIGURG) /* urgent condition on IO channel */
149 signames
[SIGURG
] = "SIGURG";
151 #if defined (SIGSTOP) /* sendable stop signal not from tty */
152 signames
[SIGSTOP
] = "SIGSTOP";
154 #if defined (SIGTSTP) /* stop signal from tty */
155 signames
[SIGTSTP
] = "SIGTSTP";
157 #if defined (SIGCONT) /* continue a stopped process */
158 signames
[SIGCONT
] = "SIGCONT";
160 #if defined (SIGCHLD) /* to parent on child stop or exit */
161 signames
[SIGCHLD
] = "SIGCHLD";
163 #if defined (SIGTTIN) /* to readers pgrp upon background tty read */
164 signames
[SIGTTIN
] = "SIGTTIN";
166 #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */
167 signames
[SIGTTOU
] = "SIGTTOU";
169 #if defined (SIGIO) /* input/output possible signal */
170 signames
[SIGIO
] = "SIGIO";
172 #if defined (SIGXCPU) /* exceeded CPU time limit */
173 signames
[SIGXCPU
] = "SIGXCPU";
175 #if defined (SIGXFSZ) /* exceeded file size limit */
176 signames
[SIGXFSZ
] = "SIGXFSZ";
178 #if defined (SIGVTALRM) /* virtual time alarm */
179 signames
[SIGVTALRM
] = "SIGVTALRM";
181 #if defined (SIGPROF) /* profiling time alarm */
182 signames
[SIGPROF
] = "SIGPROF";
184 #if defined (SIGWINCH) /* window changed */
185 signames
[SIGWINCH
] = "SIGWINCH";
187 #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
188 signames
[SIGLOST
] = "SIGLOST";
190 #if defined (SIGUSR1) /* user defined signal 1 */
191 signames
[SIGUSR1
] = "SIGUSR1";
193 #if defined (SIGUSR2) /* user defined signal 2 */
194 signames
[SIGUSR2
] = "SIGUSR2";
196 #if defined (SIGMSG) /* HFT input data pending */
197 signames
[SIGMSG
] = "SIGMSG";
199 #if defined (SIGPWR) /* power failure imminent (save your data) */
200 signames
[SIGPWR
] = "SIGPWR";
202 #if defined (SIGDANGER) /* system crash imminent */
203 signames
[SIGDANGER
] = "SIGDANGER";
205 #if defined (SIGMIGRATE) /* migrate process to another CPU */
206 signames
[SIGMIGRATE
] = "SIGMIGRATE";
208 #if defined (SIGPRE) /* programming error */
209 signames
[SIGPRE
] = "SIGPRE";
211 #if defined (SIGGRANT) /* HFT monitor mode granted */
212 signames
[SIGGRANT
] = "SIGGRANT";
214 #if defined (SIGRETRACT) /* HFT monitor mode retracted */
215 signames
[SIGRETRACT
] = "SIGRETRACT";
217 #if defined (SIGSOUND) /* HFT sound sequence has completed */
218 signames
[SIGSOUND
] = "SIGSOUND";
221 for (i
= 0; i
< NSIG
; i
++)
222 if (signames
[i
] == (char *)NULL
) {
223 signames
[i
] = (char *)malloc (16);;
224 sprintf (signames
[i
], "signal %d", i
);