5 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
8 System header file <signal.h>
9 Based on SUSv2 with help from C99.
12 #include <sys/_types.h>
13 #include <sys/cdefs.h>
15 typedef void __sighandler_t (int);
17 #define SIG_DFL ((__sighandler_t *)0) /* default signal handling */
18 #define SIG_IGN ((__sighandler_t *)1) /* ignore this signal */
19 #if !defined(_ANSI_SOURCE)
20 #define SIG_HOLD ((__sighandler_t *)2) /* hold this signal */
22 #define SIG_ERR ((__sighandler_t *)-1) /* return from signal() on error */
24 typedef AROS_SIG_ATOMIC_T
sig_atomic_t;
26 /* Definitions to make signal manipulation easier. From FreeBSD */
28 #define _SIG_MAXSIG (_SIG_WORDS * 32)
29 #define _SIG_IDX(sig) ((sig) - 1)
30 #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
31 #define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
32 #define _SIG_VALID(sig) ((sig) < _SIG_MAXSIG && (sig) > 0)
34 /* Almost all the remaining definitions are not part of ANSI C */
35 #if !defined(_ANSI_SOURCE)
37 typedef struct __sigset
{
38 unsigned int __val
[_SIG_WORDS
];
41 #ifndef __AROS_PID_T_DECLARED
42 #define __AROS_PID_T_DECLARED
43 typedef __pid_t pid_t
;
46 #endif /* !_ANSI_SOURCE */
49 #define SIGHUP 1 /* hangup */
50 #define SIGINT 2 /* interrupt */
51 #define SIGQUIT 3 /* quit */
52 #define SIGILL 4 /* illegal instr. */
53 #if !defined(_POSIX_SOURCE)
54 #define SIGTRAP 5 /* trace/breakpoint track */
56 #define SIGABRT 6 /* abort() */
57 #if !defined(_POSIX_SOURCE)
58 #define SIGEMT 7 /* EMT instruction (emulator trap) */
60 #define SIGFPE 8 /* floating point exception */
61 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
62 #if !defined(_POSIX_SOURCE)
63 #define SIGBUS 10 /* bus error */
65 #define SIGSEGV 11 /* segmentation violation */
66 #if !defined(_POSIX_SOURCE)
67 #define SIGSYS 12 /* non-existent system call */
69 #define SIGPIPE 13 /* write on a pipe without a reader */
70 #define SIGALRM 14 /* alarm clock */
71 #define SIGTERM 15 /* software termination */
72 #if !defined(_POSIX_SOURCE)
73 #define SIGURG 16 /* urgent IO condition */
75 #define SIGSTOP 17 /* sendable stop signal */
76 #define SIGTSTP 18 /* terminal stop signal */
77 #define SIGCONT 19 /* continue a stopped process */
78 #define SIGCHLD 20 /* to parent on child stop or exit */
79 #define SIGTTIN 21 /* to reader to background tty read */
80 #define SIGTTOU 22 /* to writer on background tty write */
81 #if !defined(_POSIX_SOURCE)
82 #define SIGXCPU 23 /* exceeded CPU time limit */
83 #define SIGXFSZ 24 /* exceeded file size limit */
84 #define SIGVTALRM 25 /* virtual timer alarm */
85 #define SIGPROF 26 /* profiling time alarm */
86 #define SIGWINCH 27 /* window size changes */
88 #define SIGUSR1 28 /* user defined signal 1 */
89 #define SIGUSR2 29 /* user defined signal 2 */
91 #if !defined(_POSIX_SOURCE)
92 /* BSD defines SIGIO and SIGINFO, we should probably include these */
93 #define SIGIO 30 /* IO event */
94 #define SIGINFO 31 /* terminal info request */
97 #if defined(_P1003_1B_VISIBLE)
99 /* Real time signals as specified by POSIX 1003.1B */
137 /* Value passed to sigevent() SIGEV_THREAD functions */
145 sigevent() is an advanced call that allows a process to request the
146 system to perform more advanced signal delivery that calling signal
149 AROS allows for signals to be queued, delivered normally, or by
150 creating a new thread and calling a function.
152 See the sigevent() manual page for more information.
156 int sigev_notify
; /* notification type */
158 int __sigev_signo
; /* signal number */
160 void (*__sigev_notify_function
)(union sigval
);
161 } __sigev_notify_call
; /* call a function */
163 union sigval sigev_value
; /* signal value */
166 /* Send a signal to the process */
167 #define sigev_signo __sigev_u.__sigev_signo
171 XXX Note that we do not support sigev_notify_attributes
173 #define sigev_notify_function \
174 __sigev_u.__sigev_notify_call.__sigenv_notify_function
176 #define SIGEV_NONE 0 /* No notification */
177 #define SIGEV_SIGNAL 1 /* Generate a queued signal */
178 #define SIGEV_THREAD 2 /* Call a notification function */
181 siginfo_t is delivered to sigaction() style signal handlers.
182 It's part of the POSIX Realtime Extension
184 typedef struct __siginfo
186 int si_signo
; /* signal number */
187 int si_errno
; /* errno value */
188 int si_code
; /* signal code */
189 pid_t si_pid
; /* sending process ID */
190 __uid_t si_uid
; /* user ID of sending process XXX */
191 void * si_addr
; /* address of faulting instruction */
192 int si_status
; /* exit value or signal */
193 long si_band
; /* band event for SIGPOLL */
194 union sigval si_value
; /* signal value */
197 #endif /* P1003_1B_VISIBLE */
199 #if !defined(_ANSI_SOURCE)
204 sigaction() provides an advanced interface for setting signal handling
210 void (*__sa_handler
)(int);
211 void (*__sa_sigaction
)(int, struct __siginfo
*, void *);
212 } __sigaction_u
; /* signal handler */
213 int sa_flags
; /* see below */
214 sigset_t sa_mask
; /* signal mask to apply */
217 #define sa_handler __sigaction_u.__sa_handler
219 #if !defined(_POSIX_SOURCE)
221 #define __need_size_t
224 /* if SA_SIGINFO is set, use sa_sigaction rather than sa_handler */
225 #define sa_sigaction __sigaction_u.__sa_sigaction
227 #define SA_NOCLDSTOP 0x0001
228 #define SA_ONSTACK 0x0002
229 #define SA_RESETHAND 0x0004
230 #define SA_RESTART 0x0008
231 #define SA_SIGINFO 0x0010
232 #define SA_NOCLDWAIT 0x0020
233 #define SA_NODEFER 0x0040
235 /* For sigaltstack() and the sigaltstack structure */
236 typedef struct sigaltstack
238 void *ss_sp
; /* signal stack base */
239 size_t ss_size
; /* signal stack size */
240 int ss_flags
; /* SS_DISABLE and/or SS_ONSTACK */
243 #define SS_ONSTACK 0x0001
244 #define SS_DISABLE 0x0002
248 int ss_onstack
; /* non-zero when signal stack in use */
249 void *ss_sp
; /* signal stack pointer */
252 #define MINSIGSTKSZ 8192
253 #define SIGSTKSZ (MINSIGSTKSZ + 40960)
255 /* XXX - We need ucontext_t */
257 /* Reasons why a signal was generated */
260 #define ILL_ILLOPC 1 /* illegal opcode */
261 #define ILL_ILLOPN 2 /* illegal operand */
262 #define ILL_ILLADR 3 /* illegal address mode */
263 #define ILL_ILLTRP 4 /* illegal trap */
264 #define ILL_PRVOPC 5 /* priviledged opcode */
265 #define ILL_PRVREG 6 /* priviledged register */
266 #define ILL_COPROC 7 /* coprocessor error */
267 #define ILL_BADSTACK 8 /* internal stack error */
270 #define FPE_INTDIV 1 /* integer divide by zero */
271 #define FPE_INTOVF 2 /* integer overflow */
272 #define FPE_FLTDIV 3 /* floating point divide by zero */
273 #define FPE_FLTOVF 4 /* floating point overflow */
274 #define FPE_FLTUND 5 /* floating point underflow */
275 #define FPE_FLTRES 6 /* floating point inexact result */
276 #define FPE_FLTINV 7 /* invalid floating point operation */
277 #define FPE_FLTSUB 8 /* subscript out of range */
280 #define SEGV_MAPERR 1 /* address not mapped to object */
281 #define SEGV_ACCERR 2 /* invalid permissions for object */
284 #define BUS_ADRALN 1 /* Address alignment */
285 #define BUS_ADRERR 2 /* Bus address error */
286 #define BUS_OBJERR 3 /* object specific hardware error */
289 #define TRAP_BRKPT 1 /* Process breakpoint */
290 #define TRAP_TRACE 2 /* Process trace trap */
293 #define CLD_EXITED 1 /* Child has exited */
294 #define CLD_KILL 2 /* Child terminated abnormally */
295 #define CLD_CORE 3 /* Child dumped core */
296 #define CLD_TRAPPED 4 /* Traced child has trapped */
297 #define CLD_STOPPED 5 /* Traced child has stopped */
298 #define CLD_CONTINUED 6 /* Traced child has continued */
301 #define POLL_IN 1 /* data input available */
302 #define POLL_OUT 2 /* data output available */
303 #define POLL_MSG 3 /* input message available */
304 #define POLL_ERR 4 /* I/O error */
305 #define POLL_PRI 5 /* high priority input available */
306 #define POLL_HUP 6 /* device disconnected */
309 #define SI_USER 0x10001 /* Signal sent by kill() */
310 #define SI_QUEUE 0x10002 /* Signal sent by sigqueue() */
311 #define SI_TIMER 0x10003 /* Signal sent by timer */
312 #define SI_ASYNCIO 0x10004 /* Signal sent by async I/O */
313 #define SI_MESGQ 0x10005 /* Signal generated by message queue */
315 /* Tag for struct timespec */
318 #endif /* !_POSIX_SOURCE */
320 /* Flags for sigprocmask() */
322 #define SIG_UNBLOCK 2
323 #define SIG_SETMASK 34
325 #endif /* !_ANSI_SOURCE */
327 /* Function Prototypes */
331 __sighandler_t
*signal(int, __sighandler_t
*);
333 #if !defined(_ANSI_SOURCE)
334 int kill(pid_t
, int);
336 int sigaction(int, const struct sigaction
*, struct sigaction
*);
337 int sigaddset(sigset_t
*, int);
338 int sigdelset(sigset_t
*, int);
339 int sigemptyset(sigset_t
*);
340 int sigfillset(sigset_t
*);
341 /* NOTIMPL int sighold(int); */
342 /* NOTIMPL int sigignore(int); */
343 int sigismember(const sigset_t
*, int);
344 int sigpending(sigset_t
*);
345 int sigprocmask(int, const sigset_t
*, sigset_t
*);
346 /* NOTIMPL int sigrelse(int); */
347 /* NOTIMPL int sigset(__sighandler_t *, int); */
348 int sigsuspend(const sigset_t
*);
349 /* NOTIMPL int sigwait(const sigset_t *, int *); */
351 #if !defined(_POSIX_SOURCE)
352 /* NOTIMPL int killpg(pid_t, int); */
353 /* NOTIMPL int sigaltstack(const stack_t *, stack_t *); */
354 /* NOTIMPL int siginterrupt(int); */
355 /* NOTIMPL int sigpause(int); */
356 #endif /* !_POSIX_SOURCE */
358 #if defined(_P1003_1B_VISIBLE)
359 /* NOTIMPL int sigqueue(pid_t, int, const union sigval); */
360 /* NOTIMPL int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); */
361 /* NOTIMPL int sigwaitinfo(const sigset_t *, siginfo_t *); */
362 #endif /* _P1003_1B */
364 #endif /* !_ANSI_SOURCE */
368 #endif /* _SIGNAL_H_ */