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 /* XXX Make sure that this agrees with the length in inttypes.h */
26 typedef AROS_ATOMIC_TYPE
sig_atomic_t;
29 /* Definitions to make signal manipulation easier. From FreeBSD */
31 #define _SIG_MAXSIG (_SIG_WORDS * 32)
32 #define _SIG_IDX(sig) ((sig) - 1)
33 #define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
34 #define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
35 #define _SIG_VALID(sig) ((sig) < _SIG_MAXSIG && (sig) > 0)
37 /* Almost all the remaining definitions are not part of ANSI C */
38 #if !defined(_ANSI_SOURCE)
40 typedef struct __sigset
{
41 unsigned int __val
[_SIG_WORDS
];
44 #ifndef __AROS_PID_T_DECLARED
45 #define __AROS_PID_T_DECLARED
46 typedef __pid_t pid_t
;
49 #endif /* !_ANSI_SOURCE */
52 #define SIGHUP 1 /* hangup */
53 #define SIGINT 2 /* interrupt */
54 #define SIGQUIT 3 /* quit */
55 #define SIGILL 4 /* illegal instr. */
56 #if !defined(_POSIX_SOURCE)
57 #define SIGTRAP 5 /* trace/breakpoint track */
59 #define SIGABRT 6 /* abort() */
60 #if !defined(_POSIX_SOURCE)
61 #define SIGEMT 7 /* EMT instruction (emulator trap) */
63 #define SIGFPE 8 /* floating point exception */
64 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
65 #if !defined(_POSIX_SOURCE)
66 #define SIGBUS 10 /* bus error */
68 #define SIGSEGV 11 /* segmentation violation */
69 #if !defined(_POSIX_SOURCE)
70 #define SIGSYS 12 /* non-existent system call */
72 #define SIGPIPE 13 /* write on a pipe without a reader */
73 #define SIGALRM 14 /* alarm clock */
74 #define SIGTERM 15 /* software termination */
75 #if !defined(_POSIX_SOURCE)
76 #define SIGURG 16 /* urgent IO condition */
78 #define SIGSTOP 17 /* sendable stop signal */
79 #define SIGTSTP 18 /* terminal stop signal */
80 #define SIGCONT 19 /* continue a stopped process */
81 #define SIGCHLD 20 /* to parent on child stop or exit */
82 #define SIGTTIN 21 /* to reader to background tty read */
83 #define SIGTTOU 22 /* to writer on background tty write */
84 #if !defined(_POSIX_SOURCE)
85 #define SIGXCPU 23 /* exceeded CPU time limit */
86 #define SIGXFSZ 24 /* exceeded file size limit */
87 #define SIGVTALRM 25 /* virtual timer alarm */
88 #define SIGPROF 26 /* profiling time alarm */
89 #define SIGWINCH 27 /* window size changes */
91 #define SIGUSR1 28 /* user defined signal 1 */
92 #define SIGUSR2 29 /* user defined signal 2 */
94 #if !defined(_POSIX_SOURCE)
95 /* BSD defines SIGIO and SIGINFO, we should probably include these */
96 #define SIGIO 30 /* IO event */
97 #define SIGINFO 31 /* terminal info request */
100 #if defined(_P1003_1B_VISIBLE)
102 /* Real time signals as specified by POSIX 1003.1B */
140 /* Value passed to sigevent() SIGEV_THREAD functions */
148 sigevent() is an advanced call that allows a process to request the
149 system to perform more advanced signal delivery that calling signal
152 AROS allows for signals to be queued, delivered normally, or by
153 creating a new thread and calling a function.
155 See the sigevent() manual page for more information.
159 int sigev_notify
; /* notification type */
161 int __sigev_signo
; /* signal number */
163 void (*__sigev_notify_function
)(union sigval
);
164 } __sigev_notify_call
; /* call a function */
166 union sigval sigev_value
; /* signal value */
169 /* Send a signal to the process */
170 #define sigev_signo __sigev_u.__sigev_signo
174 XXX Note that we do not support sigev_notify_attributes
176 #define sigev_notify_function \
177 __sigev_u.__sigev_notify_call.__sigenv_notify_function
179 #define SIGEV_NONE 0 /* No notification */
180 #define SIGEV_SIGNAL 1 /* Generate a queued signal */
181 #define SIGEV_THREAD 2 /* Call a notification function */
184 siginfo_t is delivered to sigaction() style signal handlers.
185 It's part of the POSIX Realtime Extension
187 typedef struct __siginfo
189 int si_signo
; /* signal number */
190 int si_errno
; /* errno value */
191 int si_code
; /* signal code */
192 pid_t si_pid
; /* sending process ID */
193 __uid_t si_uid
; /* user ID of sending process XXX */
194 void * si_addr
; /* address of faulting instruction */
195 int si_status
; /* exit value or signal */
196 long si_band
; /* band event for SIGPOLL */
197 union sigval si_value
; /* signal value */
200 #endif /* P1003_1B_VISIBLE */
202 #if !defined(_ANSI_SOURCE)
207 sigaction() provides an advanced interface for setting signal handling
213 void (*__sa_handler
)(int);
214 void (*__sa_sigaction
)(int, struct __siginfo
*, void *);
215 } __sigaction_u
; /* signal handler */
216 int sa_flags
; /* see below */
217 sigset_t sa_mask
; /* signal mask to apply */
220 #define sa_handler __sigaction_u.__sa_handler
222 #if !defined(_POSIX_SOURCE)
224 #define __need_size_t
227 /* if SA_SIGINFO is set, use sa_sigaction rather than sa_handler */
228 #define sa_sigaction __sigaction_u.__sa_sigaction
230 #define SA_NOCLDSTOP 0x0001
231 #define SA_ONSTACK 0x0002
232 #define SA_RESETHAND 0x0004
233 #define SA_RESTART 0x0008
234 #define SA_SIGINFO 0x0010
235 #define SA_NOCLDWAIT 0x0020
236 #define SA_NODEFER 0x0040
238 /* For sigaltstack() and the sigaltstack structure */
239 typedef struct sigaltstack
241 void *ss_sp
; /* signal stack base */
242 size_t ss_size
; /* signal stack size */
243 int ss_flags
; /* SS_DISABLE and/or SS_ONSTACK */
246 #define SS_ONSTACK 0x0001
247 #define SS_DISABLE 0x0002
251 int ss_onstack
; /* non-zero when signal stack in use */
252 void *ss_sp
; /* signal stack pointer */
255 #define MINSIGSTKSZ 8192
256 #define SIGSTKSZ (MINSIGSTKSZ + 40960)
258 /* XXX - We need ucontext_t */
260 /* Reasons why a signal was generated */
263 #define ILL_ILLOPC 1 /* illegal opcode */
264 #define ILL_ILLOPN 2 /* illegal operand */
265 #define ILL_ILLADR 3 /* illegal address mode */
266 #define ILL_ILLTRP 4 /* illegal trap */
267 #define ILL_PRVOPC 5 /* priviledged opcode */
268 #define ILL_PRVREG 6 /* priviledged register */
269 #define ILL_COPROC 7 /* coprocessor error */
270 #define ILL_BADSTACK 8 /* internal stack error */
273 #define FPE_INTDIV 1 /* integer divide by zero */
274 #define FPE_INTOVF 2 /* integer overflow */
275 #define FPE_FLTDIV 3 /* floating point divide by zero */
276 #define FPE_FLTOVF 4 /* floating point overflow */
277 #define FPE_FLTUND 5 /* floating point underflow */
278 #define FPE_FLTRES 6 /* floating point inexact result */
279 #define FPE_FLTINV 7 /* invalid floating point operation */
280 #define FPE_FLTSUB 8 /* subscript out of range */
283 #define SEGV_MAPERR 1 /* address not mapped to object */
284 #define SEGV_ACCERR 2 /* invalid permissions for object */
287 #define BUS_ADRALN 1 /* Address alignment */
288 #define BUS_ADRERR 2 /* Bus address error */
289 #define BUS_OBJERR 3 /* object specific hardware error */
292 #define TRAP_BRKPT 1 /* Process breakpoint */
293 #define TRAP_TRACE 2 /* Process trace trap */
296 #define CLD_EXITED 1 /* Child has exited */
297 #define CLD_KILL 2 /* Child terminated abnormally */
298 #define CLD_CORE 3 /* Child dumped core */
299 #define CLD_TRAPPED 4 /* Traced child has trapped */
300 #define CLD_STOPPED 5 /* Traced child has stopped */
301 #define CLD_CONTINUED 6 /* Traced child has continued */
304 #define POLL_IN 1 /* data input available */
305 #define POLL_OUT 2 /* data output available */
306 #define POLL_MSG 3 /* input message available */
307 #define POLL_ERR 4 /* I/O error */
308 #define POLL_PRI 5 /* high priority input available */
309 #define POLL_HUP 6 /* device disconnected */
312 #define SI_USER 0x10001 /* Signal sent by kill() */
313 #define SI_QUEUE 0x10002 /* Signal sent by sigqueue() */
314 #define SI_TIMER 0x10003 /* Signal sent by timer */
315 #define SI_ASYNCIO 0x10004 /* Signal sent by async I/O */
316 #define SI_MESGQ 0x10005 /* Signal generated by message queue */
318 /* Tag for struct timespec */
321 #endif /* !_POSIX_SOURCE */
323 /* Flags for sigprocmask() */
325 #define SIG_UNBLOCK 2
326 #define SIG_SETMASK 34
328 #endif /* !_ANSI_SOURCE */
330 /* Function Prototypes */
334 __sighandler_t
*signal(int, __sighandler_t
*);
336 #if !defined(_ANSI_SOURCE)
337 int kill(pid_t
, int);
339 int sigaction(int, const struct sigaction
*, struct sigaction
*);
340 int sigaddset(sigset_t
*, int);
341 int sigdelset(sigset_t
*, int);
342 int sigemptyset(sigset_t
*);
343 int sigfillset(sigset_t
*);
344 /* NOTIMPL int sighold(int); */
345 /* NOTIMPL int sigignore(int); */
346 int sigismember(const sigset_t
*, int);
347 int sigpending(sigset_t
*);
348 int sigprocmask(int, const sigset_t
*, sigset_t
*);
349 /* NOTIMPL int sigrelse(int); */
350 /* NOTIMPL int sigset(__sighandler_t *, int); */
351 int sigsuspend(const sigset_t
*);
352 /* NOTIMPL int sigwait(const sigset_t *, int *); */
354 #if !defined(_POSIX_SOURCE)
355 /* NOTIMPL int killpg(pid_t, int); */
356 /* NOTIMPL int sigaltstack(const stack_t *, stack_t *); */
357 /* NOTIMPL int siginterrupt(int); */
358 /* NOTIMPL int sigpause(int); */
359 #endif /* !_POSIX_SOURCE */
361 #if defined(_P1003_1B_VISIBLE)
362 /* NOTIMPL int sigqueue(pid_t, int, const union sigval); */
363 /* NOTIMPL int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); */
364 /* NOTIMPL int sigwaitinfo(const sigset_t *, siginfo_t *); */
365 #endif /* _P1003_1B */
367 #endif /* !_ANSI_SOURCE */
371 #endif /* _SIGNAL_H_ */