2 * D header file for POSIX.
4 * Copyright: Public Domain
5 * License: Public Domain
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 module core.sys.posix.signal;
11 private import core.sys.posix.config;
12 public import core.stdc.signal;
13 public import core.stdc.stddef; // for size_t
14 public import core.sys.posix.sys.types; // for pid_t
15 //public import core.sys.posix.time; // for timespec, now defined here
19 private alias void function(int) sigfn_t;
20 private alias void function(int, siginfo_t*, void*) sigactfn_t;
26 SIG_DFL (defined in core.stdc.signal)
27 SIG_ERR (defined in core.stdc.signal)
28 SIG_IGN (defined in core.stdc.signal)
30 sig_atomic_t (defined in core.stdc.signal)
45 SIGABRT (defined in core.stdc.signal)
50 SIGFPE (defined in core.stdc.signal)
52 SIGILL (defined in core.stdc.signal)
53 SIGINT (defined in core.stdc.signal)
57 SIGSEGV (defined in core.stdc.signal)
59 SIGTERM (defined in core.stdc.signal)
71 sigactfn_t sa_sigaction;
74 sigfn_t signal(int sig, sigfn_t func); (defined in core.stdc.signal)
75 int raise(int sig); (defined in core.stdc.signal)
78 //SIG_DFL (defined in core.stdc.signal)
79 //SIG_ERR (defined in core.stdc.signal)
80 //SIG_IGN (defined in core.stdc.signal)
82 //sig_atomic_t (defined in core.stdc.signal)
97 private extern (C) int __libc_current_sigrtmin();
98 private extern (C) int __libc_current_sigrtmax();
100 alias __libc_current_sigrtmin SIGRTMIN;
101 alias __libc_current_sigrtmax SIGRTMAX;
105 //SIGABRT (defined in core.stdc.signal)
110 //SIGFPE (defined in core.stdc.signal)
112 //SIGILL (defined in core.stdc.signal)
113 //SIGINT (defined in core.stdc.signal)
117 //SIGSEGV (defined in core.stdc.signal)
119 //SIGTERM (defined in core.stdc.signal)
127 else version( darwin )
129 //SIGABRT (defined in core.stdc.signal)
134 //SIGFPE (defined in core.stdc.signal)
136 //SIGILL (defined in core.stdc.signal)
137 //SIGINT (defined in core.stdc.signal)
141 //SIGSEGV (defined in core.stdc.signal)
143 //SIGTERM (defined in core.stdc.signal)
151 else version( freebsd )
153 //SIGABRT (defined in core.stdc.signal)
158 //SIGFPE (defined in core.stdc.signal)
160 //SIGILL (defined in core.stdc.signal)
161 //SIGINT (defined in core.stdc.signal)
165 //SIGSEGV (defined in core.stdc.signal)
167 //SIGTERM (defined in core.stdc.signal)
178 static if( true /* __USE_POSIX199309 */ )
183 sigactfn_t sa_sigaction;
193 version( darwin ) {} else {
194 void function() sa_restorer;
205 pid_t (defined in core.sys.types)
207 SIGABRT (defined in core.stdc.signal)
208 SIGFPE (defined in core.stdc.signal)
209 SIGILL (defined in core.stdc.signal)
210 SIGINT (defined in core.stdc.signal)
211 SIGSEGV (defined in core.stdc.signal)
212 SIGTERM (defined in core.stdc.signal)
214 SA_NOCLDSTOP (CX|XSI)
245 int kill(pid_t, int);
246 int sigaction(int, in sigaction_t*, sigaction_t*);
247 int sigaddset(sigset_t*, int);
248 int sigdelset(sigset_t*, int);
249 int sigemptyset(sigset_t*);
250 int sigfillset(sigset_t*);
251 int sigismember(in sigset_t*, int);
252 int sigpending(sigset_t*);
253 int sigprocmask(int, in sigset_t*, sigset_t*);
254 int sigsuspend(in sigset_t*);
255 int sigwait(in sigset_t*, int*);
260 const SIG_HOLD = cast(sigfn_t) 1;
262 private const _SIGSET_NWORDS = 1024 / (8 * c_ulong.sizeof);
266 c_ulong[_SIGSET_NWORDS] __val;
269 // pid_t (defined in core.sys.types)
271 //SIGABRT (defined in core.stdc.signal)
272 //SIGFPE (defined in core.stdc.signal)
273 //SIGILL (defined in core.stdc.signal)
274 //SIGINT (defined in core.stdc.signal)
275 //SIGSEGV (defined in core.stdc.signal)
276 //SIGTERM (defined in core.stdc.signal)
278 const SA_NOCLDSTOP = 1; // (CX|XSI)
281 const SIG_UNBLOCK = 1;
282 const SIG_SETMASK = 2;
284 private const __SI_MAX_SIZE = 128;
286 static if( false /* __WORDSIZE == 64 */ )
288 private const __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 4);
292 private const __SI_PAD_SIZE = ((__SI_MAX_SIZE / int.sizeof) - 3);
297 int si_signo; // Signal number
298 int si_errno; // If non-zero, an errno value associated with
299 // this signal, as defined in <errno.h>
300 int si_code; // Signal code
304 int _pad[__SI_PAD_SIZE];
309 pid_t si_pid; // Sending process ID
310 uid_t si_uid; // Real user ID of sending process
316 int si_tid; // Timer ID
317 int si_overrun; // Overrun count
318 sigval si_sigval; // Signal value
324 pid_t si_pid; // Sending process ID
325 uid_t si_uid; // Real user ID of sending process
326 sigval si_sigval; // Signal value
332 pid_t si_pid; // Which child
333 uid_t si_uid; // Real user ID of sending process
334 int si_status; // Exit value or signal
337 } _sigchild_t _sigchld;
339 // SIGILL, SIGFPE, SIGSEGV, SIGBUS
342 void* si_addr; // Faulting insn/memory ref
343 } _sigfault_t _sigfault;
348 c_long si_band; // Band event for SIGPOLL
350 } _sigpoll_t _sigpoll;
351 } _sifields_t _sifields;
367 int kill(pid_t, int);
368 int sigaction(int, in sigaction_t*, sigaction_t*);
369 int sigaddset(sigset_t*, int);
370 int sigdelset(sigset_t*, int);
371 int sigemptyset(sigset_t*);
372 int sigfillset(sigset_t*);
373 int sigismember(in sigset_t*, int);
374 int sigpending(sigset_t*);
375 int sigprocmask(int, in sigset_t*, sigset_t*);
376 int sigsuspend(in sigset_t*);
377 int sigwait(in sigset_t*, int*);
379 else version( darwin )
384 // pid_t (defined in core.sys.types)
386 //SIGABRT (defined in core.stdc.signal)
387 //SIGFPE (defined in core.stdc.signal)
388 //SIGILL (defined in core.stdc.signal)
389 //SIGINT (defined in core.stdc.signal)
390 //SIGSEGV (defined in core.stdc.signal)
391 //SIGTERM (defined in core.stdc.signal)
393 //SA_NOCLDSTOP (CX|XSI)
419 int kill(pid_t, int);
420 int sigaction(int, in sigaction_t*, sigaction_t*);
421 int sigaddset(sigset_t*, int);
422 int sigdelset(sigset_t*, int);
423 int sigemptyset(sigset_t*);
424 int sigfillset(sigset_t*);
425 int sigismember(in sigset_t*, int);
426 int sigpending(sigset_t*);
427 int sigprocmask(int, in sigset_t*, sigset_t*);
428 int sigsuspend(in sigset_t*);
429 int sigwait(in sigset_t*, int*);
431 else version( freebsd )
476 ___spare___ __spare__;
481 int kill(pid_t, int);
482 int sigaction(int, in sigaction_t*, sigaction_t);
483 int sigaddset(sigset_t*, int);
484 int sigdelset(sigset_t*, int);
485 int sigemptyset(sigset_t *);
486 int sigfillset(sigset_t *);
487 int sigismember(in sigset_t *, int);
488 int sigpending(sigset_t *);
489 int sigprocmask(int, in sigset_t*, sigset_t*);
490 int sigsuspend(in sigset_t *);
491 int sigwait(in sigset_t*, int*);
518 ucontext_t // from ucontext
519 mcontext_t // from ucontext
576 sigfn_t bsd_signal(int sig, sigfn_t func);
577 sigfn_t sigset(int sig, sigfn_t func);
579 int killpg(pid_t, int);
580 int sigaltstack(in stack_t*, stack_t*);
583 int siginterrupt(int, int);
594 const SIGVTALRM = 26;
598 const SA_ONSTACK = 0x08000000;
599 const SA_RESETHAND = 0x80000000;
600 const SA_RESTART = 0x10000000;
601 const SA_SIGINFO = 4;
602 const SA_NOCLDWAIT = 2;
603 const SA_NODEFER = 0x40000000;
604 const SS_ONSTACK = 1;
605 const SS_DISABLE = 2;
606 const MINSIGSTKSZ = 2048;
607 const SIGSTKSZ = 8192;
609 //ucontext_t (defined in core.sys.posix.ucontext)
610 //mcontext_t (defined in core.sys.posix.ucontext)
688 sigfn_t bsd_signal(int sig, sigfn_t func);
689 sigfn_t sigset(int sig, sigfn_t func);
691 int killpg(pid_t, int);
692 int sigaltstack(in stack_t*, stack_t*);
695 int siginterrupt(int, int);
704 NOTE: This should actually be defined in core.sys.posix.time.
705 It is defined here instead to break a circular import.
722 else version( darwin )
730 else version( freebsd )
740 // Realtime Signals (RTS)
748 void(*)(sigval) sigev_notify_function;
749 pthread_attr_t* sigev_notify_attributes;
752 int sigqueue(pid_t, int, in sigval);
753 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
754 int sigwaitinfo(in sigset_t*, siginfo_t*);
759 private const __SIGEV_MAX_SIZE = 64;
761 static if( false /* __WORDSIZE == 64 */ )
763 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
767 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
778 int[__SIGEV_PAD_SIZE] _pad;
781 struct _sigev_thread_t
783 void function(sigval) _function;
785 } _sigev_thread_t _sigev_thread;
786 } _sigev_un_t _sigev_un;
789 int sigqueue(pid_t, int, in sigval);
790 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
791 int sigwaitinfo(in sigset_t*, siginfo_t*);
793 else version( freebsd )
805 void function(sigval) _function;
812 int sigqueue(pid_t, int, in sigval);
813 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
814 int sigwaitinfo(in sigset_t*, siginfo_t*);
820 int pthread_kill(pthread_t, int);
821 int pthread_sigmask(int, in sigset_t*, sigset_t*);
826 int pthread_kill(pthread_t, int);
827 int pthread_sigmask(int, in sigset_t*, sigset_t*);
829 else version( darwin )
831 int pthread_kill(pthread_t, int);
832 int pthread_sigmask(int, in sigset_t*, sigset_t*);
834 else version( freebsd )
836 int pthread_kill(pthread_t, int);
837 int pthread_sigmask(int, in sigset_t*, sigset_t*);