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