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