Commit /bin/cc.exe (a hardlink of /bin/gcc.exe)
[msysgit.git] / include / sys / signal.h
blob63166e67b043d3b0f86319b879625ca908d38b49
1 /* sys/signal.h */
3 #ifndef _SYS_SIGNAL_H
4 #define _SYS_SIGNAL_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 #include "_ansi.h"
11 #include <sys/features.h>
13 /* #ifndef __STRICT_ANSI__*/
15 #if defined(_POSIX_THREADS)
16 #include <sys/types.h> /* for pthread data types */
17 #endif
19 typedef unsigned long sigset_t;
21 #if defined(__rtems__)
23 #if defined(_POSIX_REALTIME_SIGNALS)
25 /* sigev_notify values
26 NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */
28 #define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */
29 /* when the event of interest occurs. */
30 #define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */
31 /* value, shall be delivered when the event of */
32 /* interest occurs. */
33 #define SIGEV_THREAD 3 /* A notification function shall be called to */
34 /* perform notification. */
36 /* Signal Generation and Delivery, P1003.1b-1993, p. 63
37 NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
38 sigev_notify_attributes to the sigevent structure. */
40 union sigval {
41 int sival_int; /* Integer signal value */
42 void *sival_ptr; /* Pointer signal value */
45 struct sigevent {
46 int sigev_notify; /* Notification type */
47 int sigev_signo; /* Signal number */
48 union sigval sigev_value; /* Signal value */
50 #if defined(_POSIX_THREADS)
51 void (*sigev_notify_function)( union sigval );
52 /* Notification function */
53 pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */
54 #endif
57 /* Signal Actions, P1003.1b-1993, p. 64 */
58 /* si_code values, p. 66 */
60 #define SI_USER 1 /* Sent by a user. kill(), abort(), etc */
61 #define SI_QUEUE 2 /* Sent by sigqueue() */
62 #define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */
63 #define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */
64 #define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */
66 typedef struct {
67 int si_signo; /* Signal number */
68 int si_code; /* Cause of the signal */
69 union sigval si_value; /* Signal value */
70 } siginfo_t;
71 #endif
73 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
75 #define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */
76 #define SA_SIGINFO 2 /* Invoke the signal catching function with */
77 /* three arguments instead of one. */
79 /* struct sigaction notes from POSIX:
81 * (1) Routines stored in sa_handler should take a single int as
82 * there argument although the POSIX standard does not require this.
83 * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
84 * application should not use both simultaneously.
87 struct sigaction {
88 int sa_flags; /* Special flags to affect behavior of signal */
89 sigset_t sa_mask; /* Additional set of signals to be blocked */
90 /* during execution of signal-catching */
91 /* function. */
92 union {
93 void (*_handler)(); /* SIG_DFL, SIG_IGN, or pointer to a function */
94 #if defined(_POSIX_REALTIME_SIGNALS)
95 void (*_sigaction)( int, siginfo_t *, void * );
96 #endif
97 } _signal_handlers;
100 #define sa_handler _signal_handlers._handler
101 #if defined(_POSIX_REALTIME_SIGNALS)
102 #define sa_sigaction _signal_handlers._sigaction
103 #endif
105 #else
107 struct sigaction
109 void (*sa_handler)(int);
110 sigset_t sa_mask;
111 int sa_flags;
114 #define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */
116 #if defined(__CYGWIN__) || defined(__MSYS__)
117 # define SA_RESTART 0x10000000 /* Restart syscall on signal return. */
118 # define SA_NODEFER 0x40000000 /* Don't automatically block the signal when
119 its handler is being executed. */
120 # define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */
121 #endif
123 #endif /* defined(__rtems__) */
125 #define SIG_SETMASK 0 /* set mask with sigprocmask() */
126 #define SIG_BLOCK 1 /* set of signals to block */
127 #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
129 /* These depend upon the type of sigset_t, which right now
130 is always a long.. They're in the POSIX namespace, but
131 are not ANSI. */
132 #define sigaddset(what,sig) (*(what) |= (1<<(sig)))
133 #define sigemptyset(what) (*(what) = 0)
135 int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
137 #if defined(_POSIX_THREADS)
138 int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
139 #endif
141 /* protos for functions found in winsup sources for CYGWIN and MSYS*/
142 #if defined(__CYGWIN__) || defined(__rtems__) || defined(__MSYS__)
143 #undef sigaddset
144 #undef sigemptyset
145 /* The first argument to kill should be pid_t. Right now
146 <sys/types.h> always defines pid_t to be int. If that ever
147 changes, then we will need to do something else, perhaps along the
148 lines of <machine/types.h>. */
149 int _EXFUN(kill, (int, int));
150 int _EXFUN(killpg, (pid_t, int));
151 int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
152 int _EXFUN(sigaddset, (sigset_t *, const int));
153 int _EXFUN(sigdelset, (sigset_t *, const int));
154 int _EXFUN(sigismember, (const sigset_t *, int));
155 int _EXFUN(sigfillset, (sigset_t *));
156 int _EXFUN(sigemptyset, (sigset_t *));
157 int _EXFUN(sigpending, (sigset_t *));
158 int _EXFUN(sigsuspend, (const sigset_t *));
159 int _EXFUN(sigpause, (int));
161 #if defined(_POSIX_THREADS)
162 int _EXFUN(pthread_kill, (pthread_t thread, int sig));
163 #endif
165 #if defined(_POSIX_REALTIME_SIGNALS)
167 /* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
168 NOTE: P1003.1c/D10, p. 39 adds sigwait(). */
170 int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
171 int _EXFUN(sigtimedwait,
172 (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
174 int _EXFUN(sigwait, (const sigset_t *set, int *sig));
176 /* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
177 int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
179 #endif /* defined(_POSIX_REALTIME_SIGNALS) */
181 #endif /* defined(__CYGWIN32__) || defined(__rtems__) || defined(__MSYS__) */
183 /* #endif __STRICT_ANSI__ */
185 #if defined(___AM29K__)
186 /* These all need to be defined for ANSI C, but I don't think they are
187 meaningful. */
188 #define SIGABRT 1
189 #define SIGFPE 1
190 #define SIGILL 1
191 #define SIGINT 1
192 #define SIGSEGV 1
193 #define SIGTERM 1
194 /* These need to be defined for POSIX, and some others do too. */
195 #define SIGHUP 1
196 #define SIGQUIT 1
197 #define NSIG 2
198 #elif defined(__GO32__)
199 #define SIGINT 1
200 #define SIGKILL 2
201 #define SIGPIPE 3
202 #define SIGFPE 4
203 #define SIGHUP 5
204 #define SIGTERM 6
205 #define SIGSEGV 7
206 #define SIGTSTP 8
207 #define SIGQUIT 9
208 #define SIGTRAP 10
209 #define SIGILL 11
210 #define SIGEMT 12
211 #define SIGALRM 13
212 #define SIGBUS 14
213 #define SIGLOST 15
214 #define SIGSTOP 16
215 #define SIGABRT 17
216 #define SIGUSR1 18
217 #define SIGUSR2 19
218 #define NSIG 20
219 #elif defined(__CYGWIN__) || defined(__MSYS__) /* BSD signals semantics */
220 #define SIGHUP 1 /* hangup */
221 #define SIGINT 2 /* interrupt */
222 #define SIGQUIT 3 /* quit */
223 #define SIGILL 4 /* illegal instruction (not reset when caught) */
224 #define SIGTRAP 5 /* trace trap (not reset when caught) */
225 #define SIGABRT 6 /* used by abort */
226 #define SIGEMT 7 /* EMT instruction */
227 #define SIGFPE 8 /* floating point exception */
228 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
229 #define SIGBUS 10 /* bus error */
230 #define SIGSEGV 11 /* segmentation violation */
231 #define SIGSYS 12 /* bad argument to system call */
232 #define SIGPIPE 13 /* write on a pipe with no one to read it */
233 #define SIGALRM 14 /* alarm clock */
234 #define SIGTERM 15 /* software termination signal from kill */
235 #define SIGURG 16 /* urgent condition on IO channel */
236 #define SIGSTOP 17 /* sendable stop signal not from tty */
237 #define SIGTSTP 18 /* stop signal from tty */
238 #define SIGCONT 19 /* continue a stopped process */
239 #define SIGCHLD 20 /* to parent on child stop or exit */
240 #define SIGCLD 20 /* System V name for SIGCHLD */
241 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
242 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
243 #define SIGIO 23 /* input/output possible signal */
244 #define SIGPOLL SIGIO /* System V name for SIGIO */
245 #define SIGXCPU 24 /* exceeded CPU time limit */
246 #define SIGXFSZ 25 /* exceeded file size limit */
247 #define SIGVTALRM 26 /* virtual time alarm */
248 #define SIGPROF 27 /* profiling time alarm */
249 #define SIGWINCH 28 /* window changed */
250 #define SIGLOST 29 /* resource lost (eg, record-lock lost) */
251 #define SIGUSR1 30 /* user defined signal 1 */
252 #define SIGUSR2 31 /* user defined signal 2 */
253 #define NSIG 32 /* signal 0 implied */
254 #else
255 #define SIGHUP 1 /* hangup */
256 #define SIGINT 2 /* interrupt */
257 #define SIGQUIT 3 /* quit */
258 #define SIGILL 4 /* illegal instruction (not reset when caught) */
259 #define SIGTRAP 5 /* trace trap (not reset when caught) */
260 #define SIGIOT 6 /* IOT instruction */
261 #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
262 #define SIGEMT 7 /* EMT instruction */
263 #define SIGFPE 8 /* floating point exception */
264 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
265 #define SIGBUS 10 /* bus error */
266 #define SIGSEGV 11 /* segmentation violation */
267 #define SIGSYS 12 /* bad argument to system call */
268 #define SIGPIPE 13 /* write on a pipe with no one to read it */
269 #define SIGALRM 14 /* alarm clock */
270 #define SIGTERM 15 /* software termination signal from kill */
272 #if defined(__rtems__)
273 #define SIGUSR1 16 /* reserved as application defined signal 1 */
274 #define SIGUSR2 17 /* reserved as application defined signal 2 */
276 #define __SIGFIRSTNOTRT SIGHUP
277 #define __SIGLASTNOTRT SIGUSR2
279 /* RTEMS does not support job control, hence no Job Control Signals are
280 defined per P1003.1b-1993, p. 60-61.
282 RTEMS does not support memory protection, hence no Memory Protection
283 Signals are defined per P1003.1b-1993, p. 60-61. */
285 /* Real-Time Signals Range, P1003.1b-1993, p. 61
286 NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
287 (which is a minimum of 8) signals.
290 #define SIGRTMIN 18
291 #define SIGRTMAX 32
293 #elif defined(__svr4__)
294 /* svr4 specifics. different signals above 15, and sigaction. */
295 #define SIGUSR1 16
296 #define SIGUSR2 17
297 #define SIGCLD 18
298 #define SIGPWR 19
299 #define SIGWINCH 20
300 #define SIGPOLL 22 /* 20 for x.out binaries!!!! */
301 #define SIGSTOP 23 /* sendable stop signal not from tty */
302 #define SIGTSTP 24 /* stop signal from tty */
303 #define SIGCONT 25 /* continue a stopped process */
304 #define SIGTTIN 26 /* to readers pgrp upon background tty read */
305 #define SIGTTOU 27 /* like TTIN for output if (tp->t_local&LTOSTOP) */
306 #define NSIG 28
307 #else
308 #define SIGURG 16 /* urgent condition on IO channel */
309 #define SIGSTOP 17 /* sendable stop signal not from tty */
310 #define SIGTSTP 18 /* stop signal from tty */
311 #define SIGCONT 19 /* continue a stopped process */
312 #define SIGCHLD 20 /* to parent on child stop or exit */
313 #define SIGCLD 20 /* System V name for SIGCHLD */
314 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
315 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
316 #define SIGIO 23 /* input/output possible signal */
317 #define SIGPOLL SIGIO /* System V name for SIGIO */
318 #define SIGXCPU 24 /* exceeded CPU time limit */
319 #define SIGXFSZ 25 /* exceeded file size limit */
320 #define SIGVTALRM 26 /* virtual time alarm */
321 #define SIGPROF 27 /* profiling time alarm */
322 #define SIGWINCH 28 /* window changed */
323 #define SIGLOST 29 /* resource lost (eg, record-lock lost) */
324 #define SIGUSR1 30 /* user defined signal 1 */
325 #define SIGUSR2 31 /* user defined signal 2 */
326 #define NSIG 32 /* signal 0 implied */
327 #endif
328 #endif
330 #ifdef __cplusplus
332 #endif
333 #endif /* _SYS_SIGNAL_H */