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 stdc.posix.signal;
11 private import stdc.posix.config;
12 public import stdc.signal;
13 public import stdc.stddef; // for size_t
14 public import stdc.posix.sys.types; // for pid_t
15 //public import stdc.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 stdc.signal)
27 SIG_ERR (defined in stdc.signal)
28 SIG_IGN (defined in stdc.signal)
30 sig_atomic_t (defined in stdc.signal)
45 SIGABRT (defined in stdc.signal)
50 SIGFPE (defined in stdc.signal)
52 SIGILL (defined in stdc.signal)
53 SIGINT (defined in stdc.signal)
57 SIGSEGV (defined in stdc.signal)
59 SIGTERM (defined in stdc.signal)
71 sigactfn_t sa_sigaction;
74 sigfn_t signal(int sig, sigfn_t func); (defined in stdc.signal)
75 int raise(int sig); (defined in stdc.signal)
78 //SIG_DFL (defined in stdc.signal)
79 //SIG_ERR (defined in stdc.signal)
80 //SIG_IGN (defined in stdc.signal)
82 //sig_atomic_t (defined in 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 stdc.signal)
110 //SIGFPE (defined in stdc.signal)
112 //SIGILL (defined in stdc.signal)
113 //SIGINT (defined in stdc.signal)
117 //SIGSEGV (defined in stdc.signal)
119 //SIGTERM (defined in stdc.signal)
127 else version( darwin )
129 //SIGABRT (defined in stdc.signal)
134 //SIGFPE (defined in stdc.signal)
136 //SIGILL (defined in stdc.signal)
137 //SIGINT (defined in stdc.signal)
141 //SIGSEGV (defined in stdc.signal)
143 //SIGTERM (defined in stdc.signal)
151 else version( freebsd )
153 //SIGABRT (defined in stdc.signal)
158 //SIGFPE (defined in stdc.signal)
160 //SIGILL (defined in stdc.signal)
161 //SIGINT (defined in stdc.signal)
165 //SIGSEGV (defined in stdc.signal)
167 //SIGTERM (defined in 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 sys.types)
207 SIGABRT (defined in stdc.signal)
208 SIGFPE (defined in stdc.signal)
209 SIGILL (defined in stdc.signal)
210 SIGINT (defined in stdc.signal)
211 SIGSEGV (defined in stdc.signal)
212 SIGTERM (defined in 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 sys.types)
271 //SIGABRT (defined in stdc.signal)
272 //SIGFPE (defined in stdc.signal)
273 //SIGILL (defined in stdc.signal)
274 //SIGINT (defined in stdc.signal)
275 //SIGSEGV (defined in stdc.signal)
276 //SIGTERM (defined in 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 sys.types)
386 //SIGABRT (defined in stdc.signal)
387 //SIGFPE (defined in stdc.signal)
388 //SIGILL (defined in stdc.signal)
389 //SIGINT (defined in stdc.signal)
390 //SIGSEGV (defined in stdc.signal)
391 //SIGTERM (defined in 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 )
484 ___spare___ __spare__;
489 int kill(pid_t, int);
490 int sigaction(int, in sigaction_t*, sigaction_t);
491 int sigaddset(sigset_t*, int);
492 int sigdelset(sigset_t*, int);
493 int sigemptyset(sigset_t *);
494 int sigfillset(sigset_t *);
495 int sigismember(in sigset_t *, int);
496 int sigpending(sigset_t *);
497 int sigprocmask(int, in sigset_t*, sigset_t*);
498 int sigsuspend(in sigset_t *);
499 int sigwait(in sigset_t*, int*);
526 ucontext_t // from ucontext
527 mcontext_t // from ucontext
584 sigfn_t bsd_signal(int sig, sigfn_t func);
585 sigfn_t sigset(int sig, sigfn_t func);
587 int killpg(pid_t, int);
588 int sigaltstack(in stack_t*, stack_t*);
591 int siginterrupt(int, int);
602 const SIGVTALRM = 26;
606 const SA_ONSTACK = 0x08000000;
607 const SA_RESETHAND = 0x80000000;
608 const SA_RESTART = 0x10000000;
609 const SA_SIGINFO = 4;
610 const SA_NOCLDWAIT = 2;
611 const SA_NODEFER = 0x40000000;
612 const SS_ONSTACK = 1;
613 const SS_DISABLE = 2;
614 const MINSIGSTKSZ = 2048;
615 const SIGSTKSZ = 8192;
617 //ucontext_t (defined in stdc.posix.ucontext)
618 //mcontext_t (defined in stdc.posix.ucontext)
696 sigfn_t bsd_signal(int sig, sigfn_t func);
697 sigfn_t sigset(int sig, sigfn_t func);
699 int killpg(pid_t, int);
700 int sigaltstack(in stack_t*, stack_t*);
703 int siginterrupt(int, int);
712 NOTE: This should actually be defined in stdc.posix.time.
713 It is defined here instead to break a circular import.
730 else version( darwin )
738 else version( freebsd )
748 // Realtime Signals (RTS)
756 void(*)(sigval) sigev_notify_function;
757 pthread_attr_t* sigev_notify_attributes;
760 int sigqueue(pid_t, int, in sigval);
761 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
762 int sigwaitinfo(in sigset_t*, siginfo_t*);
767 private const __SIGEV_MAX_SIZE = 64;
769 static if( false /* __WORDSIZE == 64 */ )
771 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 4);
775 private const __SIGEV_PAD_SIZE = ((__SIGEV_MAX_SIZE / int.sizeof) - 3);
786 int[__SIGEV_PAD_SIZE] _pad;
789 struct _sigev_thread_t
791 void function(sigval) _function;
793 } _sigev_thread_t _sigev_thread;
794 } _sigev_un_t _sigev_un;
797 int sigqueue(pid_t, int, in sigval);
798 int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
799 int sigwaitinfo(in sigset_t*, siginfo_t*);
806 int pthread_kill(pthread_t, int);
807 int pthread_sigmask(int, in sigset_t*, sigset_t*);
812 int pthread_kill(pthread_t, int);
813 int pthread_sigmask(int, in sigset_t*, sigset_t*);
815 else version( darwin )
817 int pthread_kill(pthread_t, int);
818 int pthread_sigmask(int, in sigset_t*, sigset_t*);
820 else version( freebsd )
822 int pthread_kill(pthread_t, int);
823 int pthread_sigmask(int, in sigset_t*, sigset_t*);