add some asserts
[reactos.git] / posix / include / signal.h
1 /* $Id: signal.h,v 1.5 2002/10/29 04:45:18 rex Exp $
2 */
3 /*
4 * signal.h
5 *
6 * signals. Conforming to the Single UNIX(r) Specification Version 2,
7 * System Interface & Headers Issue 5
8 *
9 * This file is part of the ReactOS Operating System.
10 *
11 * Contributors:
12 * Created by KJK::Hyperion <noog@libero.it>
13 *
14 * THIS SOFTWARE IS NOT COPYRIGHTED
15 *
16 * This source code is offered for use in the public domain. You may
17 * use, modify or distribute it freely.
18 *
19 * This code is distributed in the hope that it will be useful but
20 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
21 * DISCLAMED. This includes but is not limited to warranties of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 */
25 #ifndef __SIGNAL_H_INCLUDED__
26 #define __SIGNAL_H_INCLUDED__
27
28 /* INCLUDES */
29 #include <time.h>
30 #include <sys/types.h>
31
32 /* OBJECTS */
33
34 /* TYPES */
35 /* pre-declaration of time.h types to suppress warnings caused by circular
36 dependencies */
37 struct timespec;
38
39 typedef int sig_atomic_t; /* Integral type of an object that can be
40 accessed as an atomic entity, even in the
41 presence of asynchronous interrupts */
42
43 typedef unsigned long int sigset_t; /* Integral or structure type of an object
44 used to represent sets of signals. */
45
46 union sigval
47 {
48 int sival_int; /* integer signal value */
49 void* sival_ptr; /* pointer signal value */
50 };
51
52 struct sigevent
53 {
54 int sigev_notify; /* notification type */
55 int sigev_signo; /* signal number */
56 union sigval sigev_value; /* signal value */
57 void (* sigev_notify_function)(union sigval); /* notification function */
58 pthread_attr_t * sigev_notify_attributes; /* notification attributes */
59 };
60
61
62 typedef struct __tagsiginfo_t
63 {
64 int si_signo; /* signal number */
65 int si_errno; /* if non-zero, an errno value associated with
66 this signal, as defined in <errno.h> */
67 int si_code; /* signal code */
68 pid_t si_pid; /* sending process ID */
69 uid_t si_uid; /* real user ID of sending process */
70 void *si_addr; /* address of faulting instruction */
71 int si_status; /* exit value or signal */
72 long si_band; /* band event for SIGPOLL */
73 union sigval si_value; /* signal value */
74 } siginfo_t;
75
76 struct sigaction
77 {
78 void (* sa_handler)(int); /* what to do on receipt of signal */
79 sigset_t sa_mask; /* set of signals to be blocked during
80 execution of the signal handling function */
81 int sa_flags; /* special flags */
82 void (* sa_sigaction)(int, siginfo_t *, void *);
83 /* pointer to signal handler function
84 or one of the macros SIG_IGN or SIG_DFL */
85 };
86
87 typedef struct __tagstack_t
88 {
89 void *ss_sp; /* stack base or pointer */
90 size_t ss_size; /* stack size */
91 int ss_flags; /* flags */
92 } stack_t;
93
94 struct sigstack
95 {
96 int ss_onstack; /* non-zero when signal stack is in use */
97 void *ss_sp; /* signal stack pointer */
98 };
99
100 /* CONSTANTS */
101 #define SIG_DFL ((void (*)(int))(0xFFFFFFFF)) /* Request for default signal handling. */
102 #define SIG_ERR ((void (*)(int))(0x00000000)) /* Return value from signal() in case of error. */
103 #define SIG_IGN ((void (*)(int))(0x00000001)) /* Request that signal be ignored. */
104 #define SIG_HOLD ((void (*)(int))(0x00000002)) /* Request that signal be held. */
105
106 #define SIGEV_NONE (0) /* No asynchronous notification will be delivered \
107 when the event of interest occurs. */
108 #define SIGEV_SIGNAL (1) /* A queued signal, with an application-defined \
109 value, will be generated when the event of \
110 interest occurs. */
111 #define SIGEV_THREAD (2) /* A notification function will be called to perform \
112 notification. */
113
114 /* TODO: realtime features not supported yet */
115 #define SIGRTMIN (-1)
116 #define SIGRTMAX (-1)
117
118 #define SIGABRT ( 1) /* Process abort signal. */
119 #define SIGALRM ( 2) /* Alarm clock. */
120 #define SIGFPE ( 3) /* Erroneous arithmetic operation. */
121 #define SIGHUP ( 4) /* Hangup. */
122 #define SIGILL ( 5) /* Illegal instruction. */
123 #define SIGINT ( 6) /* Terminal interrupt signal. */
124 #define SIGKILL ( 7) /* Kill (cannot be caught or ignored). */
125 #define SIGPIPE ( 8) /* Write on a pipe with no one to read it. */
126 #define SIGQUIT ( 9) /* Terminal quit signal. */
127 #define SIGSEGV (10) /* Invalid memory reference. */
128 #define SIGTERM (11) /* Termination signal. */
129 #define SIGUSR1 (12) /* User-defined signal 1. */
130 #define SIGUSR2 (13) /* User-defined signal 2. */
131 #define SIGCHLD (14) /* Child process terminated or stopped. */
132 #define SIGCONT (15) /* Continue executing, if stopped. */
133 #define SIGSTOP (16) /* Stop executing (cannot be caught or ignored). */
134 #define SIGTSTP (17) /* Terminal stop signal. */
135 #define SIGTTIN (18) /* Background process attempting read. */
136 #define SIGTTOU (19) /* Background process attempting write. */
137 #define SIGBUS (20) /* Access to an undefined portion of a memory object. */
138 #define SIGPOLL (21) /* Pollable event. */
139 #define SIGPROF (22) /* Profiling timer expired. */
140 #define SIGSYS (23) /* Bad system call. */
141 #define SIGTRAP (24) /* Trace/breakpoint trap. */
142 #define SIGURG (25) /* High bandwidth data is available at a socket. */
143 #define SIGVTALRM (26) /* Virtual timer expired. */
144 #define SIGXCPU (27) /* CPU time limit exceeded. */
145 #define SIGXFSZ (28) /* File size limit exceeded. */
146
147 /* FIXME: the following constants need to be reviewed */
148 /* Do not generate SIGCHLD when children stop. */
149 #define SA_NOCLDSTOP (0x00000001)
150 /* The resulting set is the union of the current set and the signal set
151 pointed to by the argument set. */
152 #define SA_ONSTACK (0x00000002)
153 /* Causes signal dispositions to be set to SIG_DFL on entry to signal
154 handlers. */
155 #define SA_RESETHAND (0x00000004)
156 /* Causes certain functions to become restartable. */
157 #define SA_RESTART (0x00000008)
158 /* Causes extra information to be passed to signal handlers at the time
159 of receipt of a signal. */
160 #define SA_SIGINFO (0x00000010)
161 /* Causes implementations not to create zombie processes on child death. */
162 #define SA_NOCLDWAIT (0x00000020)
163 /* Causes signal not to be automatically blocked on entry to signal
164 handler. */
165 #define SA_NODEFER (0x00000040)
166
167 /* FIXME: the following constants need to be reviewed */
168 /* The resulting set is the intersection of the current set and the
169 complement of the signal set pointed to by the argument set. */
170 #define SIG_BLOCK (1)
171 /* The resulting set is the signal set pointed to by the argument
172 set. */
173 #define SIG_UNBLOCK (2)
174 /* Causes signal delivery to occur on an alternate stack. */
175 #define SIG_SETMASK (3)
176
177 /* FIXME: the following constants need to be reviewed */
178 /* Process is executing on an alternate signal stack. */
179 #define SS_ONSTACK (1)
180 /* Alternate signal stack is disabled. */
181 #define SS_DISABLE (2)
182
183 /* Minimum stack size for a signal handler. */ /* FIXME */
184 #define MINSIGSTKSZ (0)
185 /* Default size in bytes for the alternate signal stack. */ /* FIXME */
186 #define SIGSTKSZ (0)
187
188 /*
189 signal-specific reasons why the signal was generated
190 */
191 /* SIGILL */
192 /* illegal opcode */
193 #define ILL_ILLOPC (1)
194 /* illegal operand */
195 #define ILL_ILLOPN (2)
196 /* illegal addressing mode */
197 #define ILL_ILLADR (3)
198 /* illegal trap */
199 #define ILL_ILLTRP (4)
200 /* privileged opcode */
201 #define ILL_PRVOPC (5)
202 /* privileged register */
203 #define ILL_PRVREG (6)
204 /* coprocessor error */
205 #define ILL_COPROC (7)
206 /* internal stack error */
207 #define ILL_BADSTK (8)
208
209 /* SIGFPE */
210 /* integer divide by zero */
211 #define FPE_INTDIV
212 /* integer overflow */
213 #define FPE_INTOVF
214 /* floating point divide by zero */
215 #define FPE_FLTDIV
216 /* floating point overflow */
217 #define FPE_FLTOVF
218 /* floating point underflow */
219 #define FPE_FLTUND
220 /* floating point inexact result */
221 #define FPE_FLTRES
222 /* invalid floating point operation */
223 #define FPE_FLTINV
224 /* subscript out of range */
225 #define FPE_FLTSUB
226
227 /* SIGSEGV */
228 /* address not mapped to object */
229 #define SEGV_MAPERR
230 /* invalid permissions for mapped object */
231 #define SEGV_ACCERR
232
233 /* SIGBUS */
234 /* invalid address alignment */
235 #define BUS_ADRALN
236 /* non-existent physical address */
237 #define BUS_ADRERR
238 /* object specific hardware error */
239 #define BUS_OBJERR
240
241 /* SIGTRAP */
242 /* process breakpoint */
243 #define TRAP_BRKPT
244 /* process trace trap */
245 #define TRAP_TRACE
246
247 /* SIGCHLD */
248 /* child has exited */
249 #define CLD_EXITED
250 /* child has terminated abnormally and did not create a core file */
251 #define CLD_KILLED
252 /* child has terminated abnormally and created a core file */
253 #define CLD_DUMPED
254 /* traced child has trapped */
255 #define CLD_TRAPPED
256 /* child has stopped */
257 #define CLD_STOPPED
258 /* stopped child has continued */
259 #define CLD_CONTINUED
260
261 /* SIGPOLL */
262 /* data input available */
263 #define POLL_IN
264 /* output buffers available */
265 #define POLL_OUT
266 /* input message available */
267 #define POLL_MSG
268 /* I/O error */
269 #define POLL_ERR
270 /* high priority input available */
271 #define POLL_PRI
272 /* device disconnected */
273 #define POLL_HUP
274 /* signal sent by kill() */
275 #define SI_USER
276 /* signal sent by the sigqueue() */
277 #define SI_QUEUE
278 /* signal generated by expiration of a timer set by timer_settime() */
279 #define SI_TIMER
280 /* signal generated by completion of an asynchronous I/O request */
281 #define SI_ASYNCIO
282 /* signal generated by arrival of a message on an empty message queue */
283 #define SI_MESGQ
284
285 /* PROTOTYPES */
286 void (*bsd_signal(int, void (*)(int)))(int);
287 int kill(pid_t, int);
288 int killpg(pid_t, int);
289 int pthread_kill(pthread_t, int);
290 int pthread_sigmask(int, const sigset_t *, sigset_t *);
291 int raise(int);
292 int sigaction(int, const struct sigaction *, struct sigaction *);
293 int sigaddset(sigset_t *, int);
294 int sigaltstack(const stack_t *, stack_t *);
295 int sigdelset(sigset_t *, int);
296 int sigemptyset(sigset_t *);
297 int sigfillset(sigset_t *);
298 int sighold(int);
299 int sigignore(int);
300 int siginterrupt(int, int);
301 int sigismember(const sigset_t *, int);
302 void (*signal(int, void (*)(int)))(int);
303 int sigpause(int);
304 int sigpending(sigset_t *);
305 int sigprocmask(int, const sigset_t *, sigset_t *);
306 int sigqueue(pid_t, int, const union sigval);
307 int sigrelse(int);
308 void (*sigset(int, void (*)(int)))(int);
309 int sigstack(struct sigstack *ss,
310 struct sigstack *oss); /* LEGACY */
311 int sigsuspend(const sigset_t *);
312 int sigtimedwait(const sigset_t *, siginfo_t *,
313 const struct timespec *);
314 int sigwait(const sigset_t *set, int *sig);
315 int sigwaitinfo(const sigset_t *, siginfo_t *);
316
317 /* MACROS */
318
319 #endif /* __SIGNAL_H_INCLUDED__ */
320
321 /* EOF */
322