10 #include <sys/cdefs.h>
11 #include <sys/features.h>
12 #include <sys/types.h>
13 #include <sys/_sigset.h>
14 #include <sys/_timespec.h>
17 #if !defined(_SIGSET_T_DECLARED)
18 #define _SIGSET_T_DECLARED
19 typedef __sigset_t sigset_t
;
22 #if defined(__CYGWIN__)
23 #include <cygwin/signal.h>
26 #if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309
28 /* sigev_notify values
29 NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
31 #define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */
32 /* when the event of interest occurs. */
33 #define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */
34 /* value, shall be delivered when the event of */
35 /* interest occurs. */
36 #define SIGEV_THREAD 3 /* A notification function shall be called to */
37 /* perform notification. */
39 /* Signal Generation and Delivery, P1003.1b-1993, p. 63
40 NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
41 sigev_notify_attributes to the sigevent structure. */
44 int sival_int
; /* Integer signal value */
45 void *sival_ptr
; /* Pointer signal value */
49 int sigev_notify
; /* Notification type */
50 int sigev_signo
; /* Signal number */
51 union sigval sigev_value
; /* Signal value */
53 #if defined(_POSIX_THREADS)
54 void (*sigev_notify_function
)( union sigval
);
55 /* Notification function */
56 pthread_attr_t
*sigev_notify_attributes
; /* Notification Attributes */
60 /* Signal Actions, P1003.1b-1993, p. 64 */
61 /* si_code values, p. 66 */
63 #define SI_USER 1 /* Sent by a user. kill(), abort(), etc */
64 #define SI_QUEUE 2 /* Sent by sigqueue() */
65 #define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */
66 #define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */
67 #define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */
70 int si_signo
; /* Signal number */
71 int si_code
; /* Cause of the signal */
72 union sigval si_value
; /* Signal value */
74 #endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */
76 #if defined(__rtems__)
78 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
80 #define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */
81 #define SA_SIGINFO 0x2 /* Invoke the signal catching function with */
82 /* three arguments instead of one. */
83 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
84 #define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */
87 /* struct sigaction notes from POSIX:
89 * (1) Routines stored in sa_handler should take a single int as
90 * their argument although the POSIX standard does not require this.
91 * This is not longer true since at least POSIX.1-2008
92 * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
93 * application should not use both simultaneously.
96 typedef void (*_sig_func_ptr
)(int);
99 int sa_flags
; /* Special flags to affect behavior of signal */
100 sigset_t sa_mask
; /* Additional set of signals to be blocked */
101 /* during execution of signal-catching */
104 _sig_func_ptr _handler
; /* SIG_DFL, SIG_IGN, or pointer to a function */
105 #if defined(_POSIX_REALTIME_SIGNALS)
106 void (*_sigaction
)( int, siginfo_t
*, void * );
111 #define sa_handler _signal_handlers._handler
112 #if defined(_POSIX_REALTIME_SIGNALS)
113 #define sa_sigaction _signal_handlers._sigaction
116 #else /* defined(__rtems__) */
118 #define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
120 typedef void (*_sig_func_ptr
)(int);
124 _sig_func_ptr sa_handler
;
128 #endif /* defined(__rtems__) */
129 #endif /* defined(__CYGWIN__) */
131 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
133 * Minimum and default signal stack constants. Allow for target overrides
134 * from <sys/features.h>.
137 #define MINSIGSTKSZ 2048
140 #define SIGSTKSZ 8192
144 * Possible values for ss_flags in stack_t below.
146 #define SS_ONSTACK 0x1
147 #define SS_DISABLE 0x2
152 * Structure used in sigaltstack call.
154 typedef struct sigaltstack
{
155 void *ss_sp
; /* Stack base or pointer. */
156 int ss_flags
; /* Flags. */
157 size_t ss_size
; /* Stack size. */
161 #define SIG_SETMASK 0 /* set mask with sigprocmask() */
162 #define SIG_BLOCK 1 /* set of signals to block */
163 #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
165 int sigprocmask (int, const sigset_t
*, sigset_t
*);
168 #if __POSIX_VISIBLE >= 199506
169 int pthread_sigmask (int, const sigset_t
*, sigset_t
*);
173 int _kill (pid_t
, int);
177 int kill (pid_t
, int);
180 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
181 int killpg (pid_t
, int);
184 int sigaction (int, const struct sigaction
*, struct sigaction
*);
185 int sigaddset (sigset_t
*, const int);
186 int sigdelset (sigset_t
*, const int);
187 int sigismember (const sigset_t
*, int);
188 int sigfillset (sigset_t
*);
189 int sigemptyset (sigset_t
*);
190 int sigpending (sigset_t
*);
191 int sigsuspend (const sigset_t
*);
192 int sigwait (const sigset_t
*, int *);
194 #if !defined(__CYGWIN__) && !defined(__rtems__)
195 /* These depend upon the type of sigset_t, which right now
196 is always a long.. They're in the POSIX namespace, but
198 #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
199 #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
200 #define sigemptyset(what) (*(what) = 0, 0)
201 #define sigfillset(what) (*(what) = ~(0), 0)
202 #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
203 #endif /* !__CYGWIN__ && !__rtems__ */
204 #endif /* __POSIX_VISIBLE */
206 /* There are two common sigpause variants, both of which take an int argument.
207 If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
208 which removes the given signal from the process's signal mask; otherwise
209 you get the BSD version, which sets the process's signal mask to the given
211 #if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__)
213 int sigpause (int) __asm__ (__ASMNAME ("__xpg_sigpause"));
215 int __xpg_sigpause (int);
216 # define sigpause __xpg_sigpause
222 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
223 int sigaltstack (const stack_t
*__restrict
, stack_t
*__restrict
);
226 #if __POSIX_VISIBLE >= 199506
227 int pthread_kill (pthread_t
, int);
230 #if __POSIX_VISIBLE >= 199309
232 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
233 NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
235 int sigwaitinfo (const sigset_t
*, siginfo_t
*);
236 int sigtimedwait (const sigset_t
*, siginfo_t
*, const struct timespec
*);
237 /* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
238 int sigqueue (pid_t
, int, const union sigval
);
240 #endif /* __POSIX_VISIBLE >= 199309 */
242 /* Using __MISC_VISIBLE until POSIX Issue 8 is officially released */
245 /* POSIX Issue 8 adds sig2str() and str2sig() */
247 #if __SIZEOF_INT__ >= 4
248 #define SIG2STR_MAX 17 /* (sizeof("RTMAX+") + sizeof("4294967295") - 1) */
250 #define SIG2STR_MAX 12 /* (sizeof("RTMAX+") + sizeof("65535") - 1) */
253 int sig2str(int, char *);
254 int str2sig(const char *__restrict
, int *__restrict
);
256 #endif /* __MISC_VISIBLE */
258 #if defined(___AM29K__)
259 /* These all need to be defined for ANSI C, but I don't think they are
267 /* These need to be defined for POSIX, and some others do too. */
271 #elif defined(__GO32__)
292 #elif !defined(SIGTRAP)
293 #define SIGHUP 1 /* hangup */
294 #define SIGINT 2 /* interrupt */
295 #define SIGQUIT 3 /* quit */
296 #define SIGILL 4 /* illegal instruction (not reset when caught) */
297 #define SIGTRAP 5 /* trace trap (not reset when caught) */
298 #define SIGIOT 6 /* IOT instruction */
299 #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
300 #define SIGEMT 7 /* EMT instruction */
301 #define SIGFPE 8 /* floating point exception */
302 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
303 #define SIGBUS 10 /* bus error */
304 #define SIGSEGV 11 /* segmentation violation */
305 #define SIGSYS 12 /* bad argument to system call */
306 #define SIGPIPE 13 /* write on a pipe with no one to read it */
307 #define SIGALRM 14 /* alarm clock */
308 #define SIGTERM 15 /* software termination signal from kill */
310 #if defined(__rtems__)
311 #define SIGURG 16 /* urgent condition on IO channel */
312 #define SIGSTOP 17 /* sendable stop signal not from tty */
313 #define SIGTSTP 18 /* stop signal from tty */
314 #define SIGCONT 19 /* continue a stopped process */
315 #define SIGCHLD 20 /* to parent on child stop or exit */
316 #define SIGCLD 20 /* System V name for SIGCHLD */
317 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
318 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
319 #define SIGIO 23 /* input/output possible signal */
320 #define SIGPOLL SIGIO /* System V name for SIGIO */
321 #define SIGWINCH 24 /* window changed */
322 #define SIGUSR1 25 /* user defined signal 1 */
323 #define SIGUSR2 26 /* user defined signal 2 */
325 /* Real-Time Signals Range, P1003.1b-1993, p. 61
326 NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
327 (which is a minimum of 8) signals.
331 #define __SIGFIRSTNOTRT SIGHUP
332 #define __SIGLASTNOTRT SIGUSR2
334 #define NSIG 32 /* signal 0 implied */
336 #elif defined(__svr4__)
337 /* svr4 specifics. different signals above 15, and sigaction. */
343 #define SIGPOLL 22 /* 20 for x.out binaries!!!! */
344 #define SIGSTOP 23 /* sendable stop signal not from tty */
345 #define SIGTSTP 24 /* stop signal from tty */
346 #define SIGCONT 25 /* continue a stopped process */
347 #define SIGTTIN 26 /* to readers pgrp upon background tty read */
348 #define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */
351 #define SIGURG 16 /* urgent condition on IO channel */
352 #define SIGSTOP 17 /* sendable stop signal not from tty */
353 #define SIGTSTP 18 /* stop signal from tty */
354 #define SIGCONT 19 /* continue a stopped process */
355 #define SIGCHLD 20 /* to parent on child stop or exit */
356 #define SIGCLD 20 /* System V name for SIGCHLD */
357 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
358 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
359 #define SIGIO 23 /* input/output possible signal */
360 #define SIGPOLL SIGIO /* System V name for SIGIO */
361 #define SIGXCPU 24 /* exceeded CPU time limit */
362 #define SIGXFSZ 25 /* exceeded file size limit */
363 #define SIGVTALRM 26 /* virtual time alarm */
364 #define SIGPROF 27 /* profiling time alarm */
365 #define SIGWINCH 28 /* window changed */
366 #define SIGLOST 29 /* resource lost (eg, record-lock lost) */
367 #define SIGUSR1 30 /* user defined signal 1 */
368 #define SIGUSR2 31 /* user defined signal 2 */
369 #define NSIG 32 /* signal 0 implied */
377 #if defined(__CYGWIN__)
378 #if __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809
379 #include <sys/ucontext.h>
384 /* Some applications take advantage of the fact that <sys/signal.h>
385 * and <signal.h> are equivalent in glibc. Allow for that here. */
388 #endif /* _SYS_SIGNAL_H */