2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 * Source: $(DRUNTIMESRC core/sys/posix/_signal.d)
12 module core
.sys
.posix
.signal
;
14 import core
.sys
.posix
.config
;
15 public import core
.stdc
.signal
;
16 public import core
.sys
.posix
.sys
.types
; // for pid_t
17 public import core
.sys
.posix
.time
; // for timespec
25 else version (WatchOS
)
28 version (ARM
) version = ARM_Any
;
29 version (AArch64
) version = ARM_Any
;
30 version (HPPA
) version = HPPA_Any
;
31 version (MIPS32
) version = MIPS_Any
;
32 version (MIPS64
) version = MIPS_Any
;
33 version (PPC
) version = PPC_Any
;
34 version (PPC64
) version = PPC_Any
;
35 version (RISCV32
) version = RISCV_Any
;
36 version (RISCV64
) version = RISCV_Any
;
37 version (S390
) version = IBMZ_Any
;
38 version (SPARC
) version = SPARC_Any
;
39 version (SPARC64
) version = SPARC_Any
;
40 version (SystemZ
) version = IBMZ_Any
;
41 version (X86
) version = X86_Any
;
42 version (X86_64
) version = X86_Any
;
46 //nothrow: // this causes http://issues.dlang.org/show_bug.cgi?id=12738 (which has been fixed)
53 SIG_DFL (defined in core.stdc.signal)
54 SIG_ERR (defined in core.stdc.signal)
55 SIG_IGN (defined in core.stdc.signal)
57 sig_atomic_t (defined in core.stdc.signal)
72 SIGABRT (defined in core.stdc.signal)
77 SIGFPE (defined in core.stdc.signal)
79 SIGILL (defined in core.stdc.signal)
80 SIGINT (defined in core.stdc.signal)
84 SIGSEGV (defined in core.stdc.signal)
86 SIGTERM (defined in core.stdc.signal)
98 sigactfn_t sa_sigaction;
101 sigfn_t signal(int sig, sigfn_t func); (defined in core.stdc.signal)
102 int raise(int sig); (defined in core.stdc.signal)
105 //SIG_DFL (defined in core.stdc.signal)
106 //SIG_ERR (defined in core.stdc.signal)
107 //SIG_IGN (defined in core.stdc.signal)
109 //sig_atomic_t (defined in core.stdc.signal)
111 private alias void function(int) sigfn_t
;
112 private alias void function(int, siginfo_t
*, void*) sigactfn_t
;
117 private alias void function(int) sigfn_t2
;
118 private alias void function(int, siginfo_t
*, void*) sigactfn_t2
;
136 import core
.sys
.posix
.unistd
;
138 @property int SIGRTMIN() nothrow @nogc {
139 __gshared
static int sig
= -1;
141 sig
= cast(int)sysconf(_SC_SIGRT_MIN
);
146 @property int SIGRTMAX() nothrow @nogc {
147 __gshared
static int sig
= -1;
149 sig
= cast(int)sysconf(_SC_SIGRT_MAX
);
154 else version (FreeBSD
)
156 // Note: it appears that FreeBSD (prior to 7) and OSX do not support realtime signals
157 // https://github.com/freebsd/freebsd/blob/e79c62ff68fc74d88cb6f479859f6fae9baa5101/sys/sys/signal.h#L117
161 else version (DragonFlyBSD
)
166 else version (NetBSD
)
173 // Note: CRuntime_Bionic switched to calling these functions
174 // since Lollipop, and Glibc, UClib and Musl all implement them
175 // the same way since it's part of LSB.
176 private extern (C
) nothrow @nogc
178 int __libc_current_sigrtmin();
179 int __libc_current_sigrtmax();
182 @property int SIGRTMIN() nothrow @nogc {
183 __gshared
static int sig
= -1;
185 sig
= __libc_current_sigrtmin();
190 @property int SIGRTMAX() nothrow @nogc {
191 __gshared
static int sig
= -1;
193 sig
= __libc_current_sigrtmax();
203 //SIGABRT (defined in core.stdc.signal)
208 //SIGFPE (defined in core.stdc.signal)
210 //SIGILL (defined in core.stdc.signal)
211 //SIGINT (defined in core.stdc.signal)
215 //SIGSEGV (defined in core.stdc.signal)
217 //SIGTERM (defined in core.stdc.signal)
225 else version (HPPA_Any
)
227 //SIGABRT (defined in core.stdc.signal)
232 //SIGFPE (defined in core.stdc.signal)
234 //SIGILL (defined in core.stdc.signal)
235 //SIGINT (defined in core.stdc.signal)
239 //SIGSEGV (defined in core.stdc.signal)
241 //SIGTERM (defined in core.stdc.signal)
249 else version (MIPS_Any
)
251 //SIGABRT (defined in core.stdc.signal)
256 //SIGFPE (defined in core.stdc.signal)
258 //SIGILL (defined in core.stdc.signal)
259 //SIGINT (defined in core.stdc.signal)
263 //SIGSEGV (defined in core.stdc.signal)
265 //SIGTERM (defined in core.stdc.signal)
273 else version (PPC_Any
)
275 //SIGABRT (defined in core.stdc.signal)
280 //SIGFPE (defined in core.stdc.signal)
282 //SIGILL (defined in core.stdc.signal)
283 //SIGINT (defined in core.stdc.signal)
287 //SIGSEGV (defined in core.stdc.signal)
289 //SIGTERM (defined in core.stdc.signal)
297 else version (ARM_Any
)
299 //SIGABRT (defined in core.stdc.signal)
304 //SIGFPE (defined in core.stdc.signal)
306 //SIGILL (defined in core.stdc.signal)
307 //SIGINT (defined in core.stdc.signal)
311 //SIGSEGV (defined in core.stdc.signal)
313 //SIGTERM (defined in core.stdc.signal)
321 else version (RISCV_Any
)
323 //SIGABRT (defined in core.stdc.signal)
328 //SIGFPE (defined in core.stdc.signal)
330 //SIGILL (defined in core.stdc.signal)
331 //SIGINT (defined in core.stdc.signal)
335 //SIGSEGV (defined in core.stdc.signal)
337 //SIGTERM (defined in core.stdc.signal)
345 else version (SPARC_Any
)
347 //SIGABRT (defined in core.stdc.signal)
352 //SIGFPE (defined in core.stdc.signal)
354 //SIGILL (defined in core.stdc.signal)
355 //SIGINT (defined in core.stdc.signal)
359 //SIGSEGV (defined in core.stdc.signal)
361 //SIGTERM (defined in core.stdc.signal)
369 else version (IBMZ_Any
)
371 //SIGABRT (defined in core.stdc.signal)
376 //SIGFPE (defined in core.stdc.signal)
378 //SIGILL (defined in core.stdc.signal)
379 //SIGINT (defined in core.stdc.signal)
383 //SIGSEGV (defined in core.stdc.signal)
385 //SIGTERM (defined in core.stdc.signal)
393 else version (LoongArch64
)
395 //SIGABRT (defined in core.stdc.signal)
400 //SIGFPE (defined in core.stdc.signal)
402 //SIGILL (defined in core.stdc.signal)
403 //SIGINT (defined in core.stdc.signal)
407 //SIGSEGV (defined in core.stdc.signal)
409 //SIGTERM (defined in core.stdc.signal)
418 static assert(0, "unimplemented");
420 else version (Darwin
)
422 //SIGABRT (defined in core.stdc.signal)
427 //SIGFPE (defined in core.stdc.signal)
429 //SIGILL (defined in core.stdc.signal)
430 //SIGINT (defined in core.stdc.signal)
434 //SIGSEGV (defined in core.stdc.signal)
436 //SIGTERM (defined in core.stdc.signal)
444 else version (FreeBSD
)
446 //SIGABRT (defined in core.stdc.signal)
451 //SIGFPE (defined in core.stdc.signal)
453 //SIGILL (defined in core.stdc.signal)
454 //SIGINT (defined in core.stdc.signal)
458 //SIGSEGV (defined in core.stdc.signal)
460 //SIGTERM (defined in core.stdc.signal)
468 else version (NetBSD
)
470 //SIGABRT (defined in core.stdc.signal)
475 //SIGFPE (defined in core.stdc.signal)
477 //SIGILL (defined in core.stdc.signal)
478 //SIGINT (defined in core.stdc.signal)
482 //SIGSEGV (defined in core.stdc.signal)
484 //SIGTERM (defined in core.stdc.signal)
492 else version (OpenBSD
)
494 //SIGABRT (defined in core.stdc.signal)
499 //SIGFPE (defined in core.stdc.signal)
501 //SIGILL (defined in core.stdc.signal)
502 //SIGINT (defined in core.stdc.signal)
506 //SIGSEGV (defined in core.stdc.signal)
508 //SIGTERM (defined in core.stdc.signal)
516 else version (DragonFlyBSD
)
518 //SIGABRT (defined in core.stdc.signal)
523 //SIGFPE (defined in core.stdc.signal)
525 //SIGILL (defined in core.stdc.signal)
526 //SIGINT (defined in core.stdc.signal)
530 //SIGSEGV (defined in core.stdc.signal)
532 //SIGTERM (defined in core.stdc.signal)
540 else version (Solaris
)
542 //SIGABRT (defined in core.stdc.signal)
547 //SIGFPE (defined in core.stdc.signal)
549 //SIGILL (defined in core.stdc.signal)
550 //SIGINT (defined in core.stdc.signal)
554 //SIGSEGV (defined in core.stdc.signal)
556 //SIGTERM (defined in core.stdc.signal)
566 static assert(false, "Unsupported platform");
571 version (CRuntime_Musl
)
578 sigactfn_t sa_sigaction
;
582 void function() sa_restorer
;
585 else version (CRuntime_Bionic
)
595 sigactfn_t sa_sigaction
;
598 void function() sa_restorer
;
608 sigactfn_t sa_sigaction
;
612 void function() sa_restorer
;
616 else version (SystemZ
)
620 static if ( true /* __USE_POSIX199309 */ )
625 sigactfn_t sa_sigaction
;
632 version (CRuntime_Glibc
)
634 int __glibc_reserved0
;
642 void function() sa_restorer
;
647 else version (HPPA_Any
)
651 static if ( true /* __USE_POSIX199309 */ )
656 sigactfn_t sa_sigaction
;
663 version (CRuntime_Glibc
)
666 int __glibc_reserved0
;
676 else version (MIPS_Any
)
682 static if ( true /* __USE_POSIX199309 */ )
687 sigactfn_t sa_sigaction
;
695 void function() sa_restorer
;
697 version (CRuntime_Glibc
)
699 static if ((void*).sizeof
< 8)
704 else version (SPARC_Any
)
708 static if ( true /* __USE_POSIX199309 */ )
713 sigactfn_t sa_sigaction
;
720 version (CRuntime_Glibc
)
724 int __glibc_reserved0
;
726 void function() sa_restorer
;
731 void function() sa_restorer
;
740 static if ( true /* __USE_POSIX199309 */ )
745 sigactfn_t sa_sigaction
;
755 void function() sa_restorer
;
759 else version (FreeBSD
)
766 sigactfn_t sa_sigaction
;
772 else version (NetBSD
)
779 sigactfn_t sa_sigaction
;
785 else version (OpenBSD
)
791 sigfn_t __sa_handler
;
792 alias sa_handler
= __sa_handler
;
793 sigactfn_t __sa_sigaction
;
794 alias sa_sigaction
= __sa_sigaction
;
800 else version (DragonFlyBSD
)
807 sigactfn_t sa_sigaction
;
813 else version (Solaris
)
822 sigactfn_t sa_sigaction
;
831 else version (Darwin
)
835 static if ( true /* __USE_POSIX199309 */ )
840 sigactfn_t sa_sigaction
;
853 static assert(false, "Unsupported platform");
863 pid_t (defined in core.sys.types)
865 SIGABRT (defined in core.stdc.signal)
866 SIGFPE (defined in core.stdc.signal)
867 SIGILL (defined in core.stdc.signal)
868 SIGINT (defined in core.stdc.signal)
869 SIGSEGV (defined in core.stdc.signal)
870 SIGTERM (defined in core.stdc.signal)
872 SA_NOCLDSTOP (CX|XSI)
909 enum SIG_HOLD
= cast(sigfn_t2
) 2;
911 private enum _SIGSET_NWORDS
= 1024 / (8 * c_ulong
.sizeof
);
915 c_ulong
[_SIGSET_NWORDS
] __val
;
918 enum SA_NOCLDSTOP
= 1; // (CX|XSI)
923 enum SIG_UNBLOCK
= 2;
924 enum SIG_SETMASK
= 3;
926 else version (SPARC_Any
)
929 enum SIG_UNBLOCK
= 2;
930 enum SIG_SETMASK
= 4;
935 enum SIG_UNBLOCK
= 1;
936 enum SIG_SETMASK
= 2;
939 private enum __SI_MAX_SIZE
= 128;
941 static if ( __WORDSIZE
== 64 )
943 private enum __SI_PAD_SIZE
= ((__SI_MAX_SIZE
/ int.sizeof
) - 4);
947 private enum __SI_PAD_SIZE
= ((__SI_MAX_SIZE
/ int.sizeof
) - 3);
953 version (MIPS_Any
) // __SI_SWAP_ERRNO_CODE
966 int[__SI_PAD_SIZE
] _pad
;
998 } _sigchild_t _sigchld
;
1000 // SIGILL, SIGFPE, SIGSEGV, SIGBUS
1004 } _sigfault_t _sigfault
;
1011 } _sigpoll_t _sigpoll
;
1012 } _sifields_t _sifields
;
1015 @property ref pid_t
si_pid() return { return _sifields
._kill
.si_pid
; }
1016 @property ref uid_t
si_uid() return { return _sifields
._kill
.si_uid
; }
1017 @property ref void* si_addr() return { return _sifields
._sigfault
.si_addr
; }
1018 @property ref int si_status() return { return _sifields
._sigchld
.si_status
; }
1019 @property ref c_long
si_band() return { return _sifields
._sigpoll
.si_band
; }
1020 @property ref sigval
si_value() return { return _sifields
._rt
.si_sigval
; }
1036 else version (Darwin
)
1038 enum SIG_HOLD
= cast(sigfn_t2
) 5;
1040 alias uint sigset_t
;
1042 enum SA_NOCLDSTOP
= 8; // (CX|XSI)
1045 enum SIG_UNBLOCK
= 2;
1046 enum SIG_SETMASK
= 3;
1062 enum SI_USER
= 0x10001;
1063 enum SI_QUEUE
= 0x10002;
1064 enum SI_TIMER
= 0x10003;
1065 enum SI_ASYNCIO
= 0x10004;
1066 enum SI_MESGQ
= 0x10005;
1068 else version (FreeBSD
)
1070 enum SIG_HOLD
= cast(sigfn_t2
) 3;
1077 enum SA_NOCLDSTOP
= 8;
1080 enum SIG_UNBLOCK
= 2;
1081 enum SIG_SETMASK
= 3;
1121 ___spare___ __spare__
;
1125 @property ref c_long
si_band() return { return _reason
._poll
._band
; }
1128 enum SI_USER
= 0x10001;
1129 enum SI_QUEUE
= 0x10002;
1130 enum SI_TIMER
= 0x10003;
1131 enum SI_ASYNCIO
= 0x10004;
1132 enum SI_MESGQ
= 0x10005;
1134 else version (NetBSD
)
1136 enum SIG_HOLD
= cast(sigfn_t2
) 3;
1143 enum SA_NOCLDSTOP
= 8;
1146 enum SIG_UNBLOCK
= 2;
1147 enum SIG_SETMASK
= 3;
1199 @property ref c_long
si_band() return { return _info
._reason
._poll
._band
; }
1205 enum SI_ASYNCIO
= -3;
1208 else version (OpenBSD
)
1210 enum SIG_CATCH
= cast(sigfn_t2
) 2;
1211 enum SIG_HOLD
= cast(sigfn_t2
) 3;
1213 alias sigset_t
= uint;
1215 enum SA_NOCLDSTOP
= 0x0008;
1218 enum SIG_UNBLOCK
= 2;
1219 enum SIG_SETMASK
= 3;
1221 private enum SI_MAXSZ
= 128;
1222 private enum SI_PAD
= (SI_MAXSZ
/ int.sizeof
) - 3;
1256 alias si_pid
= _data
._proc
._pid
;
1257 alias si_status
= _data
._proc
._pdata
._cld
._status
;
1258 alias si_stime
= _data
._proc
._pdata
._cld
._stime
;
1259 alias si_utime
= _data
._proc
._pdata
._cld
._utime
;
1260 alias si_uid
= _data
._proc
._pdata
._kill
._uid
;
1261 alias si_value
= _data
._proc
._pdata
._kill
._value
;
1262 alias si_addr
= _data
._fault
._addr
;
1263 alias si_trapno
= _data
._fault
._trapno
;
1266 enum SI_NOINFO
= 32767;
1272 else version (DragonFlyBSD
)
1274 enum SIG_CATCH
= cast(sigfn_t2
) 2;
1275 enum SIG_HOLD
= cast(sigfn_t2
) 3;
1282 enum SA_NOCLDSTOP
= 8;
1285 enum SIG_UNBLOCK
= 2;
1286 enum SIG_SETMASK
= 3;
1302 enum SI_UNDEFINED
= 0x00000;
1306 enum SI_ASYNCIO
= -3;
1309 else version (Solaris
)
1311 enum SIG_HOLD
= cast(sigfn_t2
)2;
1319 enum SIG_UNBLOCK
= 2;
1320 enum SIG_SETMASK
= 3;
1334 int[(256 / int.sizeof
) - 4] si_pad
;
1336 int[(128 / int.sizeof
) - 3] si_pad
;
1389 timestruc_t __tstamp
;
1410 enum SI_NOINFO
= 32767;
1411 enum SI_DTRACE
= 2050;
1412 enum SI_RCTL
= 2049;
1417 enum SI_ASYNCIO
= -4;
1422 static assert(false, "Unsupported platform");
1426 int kill(pid_t, int);
1427 int sigaction(int, const scope sigaction_t*, sigaction_t*);
1428 int sigaddset(sigset_t*, int);
1429 int sigdelset(sigset_t*, int);
1430 int sigemptyset(sigset_t*);
1431 int sigfillset(sigset_t*);
1432 int sigismember(const scope sigset_t*, int);
1433 int sigpending(sigset_t*);
1434 int sigprocmask(int, const scope sigset_t*, sigset_t*);
1435 int sigsuspend(const scope sigset_t*);
1436 int sigwait(const scope sigset_t*, int*);
1439 version (CRuntime_Glibc
)
1441 int kill(pid_t
, int);
1442 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1443 int sigaddset(sigset_t
*, int);
1444 int sigdelset(sigset_t
*, int);
1445 int sigemptyset(sigset_t
*);
1446 int sigfillset(sigset_t
*);
1447 int sigismember(const scope sigset_t
*, int);
1448 int sigpending(sigset_t
*);
1449 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1450 int sigsuspend(const scope sigset_t
*);
1451 int sigwait(const scope sigset_t
*, int*);
1453 else version (Darwin
)
1455 int kill(pid_t
, int);
1456 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1457 int sigaddset(sigset_t
*, int);
1458 int sigdelset(sigset_t
*, int);
1459 int sigemptyset(sigset_t
*);
1460 int sigfillset(sigset_t
*);
1461 int sigismember(const scope sigset_t
*, int);
1462 int sigpending(sigset_t
*);
1463 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1464 int sigsuspend(const scope sigset_t
*);
1465 int sigwait(const scope sigset_t
*, int*);
1467 else version (FreeBSD
)
1469 int kill(pid_t
, int);
1470 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1471 int sigaddset(sigset_t
*, int);
1472 int sigdelset(sigset_t
*, int);
1473 int sigemptyset(sigset_t
*);
1474 int sigfillset(sigset_t
*);
1475 int sigismember(const scope sigset_t
*, int);
1476 int sigpending(sigset_t
*);
1477 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1478 int sigsuspend(const scope sigset_t
*);
1479 int sigwait(const scope sigset_t
*, int*);
1481 else version (NetBSD
)
1483 int kill(pid_t
, int);
1484 int __sigaction14(int, const scope sigaction_t
*, sigaction_t
*);
1485 int __sigaddset14(sigset_t
*, int);
1486 int __sigdelset14(sigset_t
*, int);
1487 int __sigemptyset14(sigset_t
*);
1488 int __sigfillset14(sigset_t
*);
1489 int __sigismember14(const scope sigset_t
*, int);
1490 int __sigpending14(sigset_t
*);
1491 int __sigprocmask14(int, const scope sigset_t
*, sigset_t
*);
1492 int __sigsuspend14(const scope sigset_t
*);
1493 int sigwait(const scope sigset_t
*, int*);
1495 alias __sigaction14 sigaction
;
1496 alias __sigaddset14 sigaddset
;
1497 alias __sigdelset14 sigdelset
;
1498 alias __sigemptyset14 sigemptyset
;
1499 alias __sigfillset14 sigfillset
;
1500 alias __sigismember14 sigismember
;
1501 alias __sigpending14 sigpending
;
1502 alias __sigprocmask14 sigprocmask
;
1503 alias __sigsuspend14 sigsuspend
;
1505 else version (OpenBSD
)
1507 int kill(pid_t
, int);
1508 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1509 int sigaddset(sigset_t
*, int);
1510 int sigdelset(sigset_t
*, int);
1511 int sigemptyset(sigset_t
*);
1512 int sigfillset(sigset_t
*);
1513 int sigismember(const scope sigset_t
*, int);
1514 int sigpending(sigset_t
*);
1515 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1516 int sigsuspend(const scope sigset_t
*);
1517 int sigwait(const scope sigset_t
*, int*);
1519 else version (DragonFlyBSD
)
1521 int kill(pid_t
, int);
1522 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1523 int sigaddset(sigset_t
*, int);
1524 int sigdelset(sigset_t
*, int);
1525 int sigemptyset(sigset_t
*);
1526 int sigfillset(sigset_t
*);
1527 int sigismember(const scope sigset_t
*, int);
1528 int sigpending(sigset_t
*);
1529 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1530 int sigsuspend(const scope sigset_t
*);
1531 int sigwait(const scope sigset_t
*, int*);
1533 else version (Solaris
)
1535 int kill(pid_t
, int);
1536 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1537 int sigaddset(sigset_t
*, int);
1538 int sigdelset(sigset_t
*, int);
1539 int sigemptyset(sigset_t
*);
1540 int sigfillset(sigset_t
*);
1541 int sigismember(const scope sigset_t
*, int);
1542 int sigpending(sigset_t
*);
1543 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1544 int sigsuspend(const scope sigset_t
*);
1545 int sigwait(const scope sigset_t
*, int*);
1547 else version (CRuntime_Bionic
)
1549 public import core
.sys
.posix
.time
: timer_t
;
1550 import core
.stdc
.string
: memset
;
1553 enum int LONG_BIT
= 32;
1555 enum int LONG_BIT
= 32;
1556 else version (AArch64
)
1557 enum int LONG_BIT
= 64;
1558 else version (X86_64
)
1559 enum int LONG_BIT
= 64;
1561 static assert(false, "Architecture not supported.");
1563 int kill(pid_t
, int);
1564 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1566 // These functions are defined inline in bionic.
1567 int sigaddset(sigset_t
* set
, int signum
)
1569 c_ulong
* local_set
= cast(c_ulong
*) set
;
1571 local_set
[signum
/LONG_BIT
] |
= 1UL << (signum
%LONG_BIT
);
1575 int sigdelset(sigset_t
* set
, int signum
)
1577 c_ulong
* local_set
= cast(c_ulong
*) set
;
1579 local_set
[signum
/LONG_BIT
] &= ~(1UL << (signum
%LONG_BIT
));
1583 int sigemptyset(sigset_t
* set
) { memset(set
, 0, (*set
).sizeof
); return 0; }
1585 int sigfillset(sigset_t
* set
) { memset(set
, ~0, (*set
).sizeof
); return 0; }
1587 int sigismember(sigset_t
* set
, int signum
)
1589 c_ulong
* local_set
= cast(c_ulong
*) set
;
1591 return cast(int) ((local_set
[signum
/LONG_BIT
] >> (signum
%LONG_BIT
)) & 1);
1594 int sigpending(sigset_t
*);
1595 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1596 int sigsuspend(const scope sigset_t
*);
1597 int sigwait(const scope sigset_t
*, int*);
1599 else version (CRuntime_Musl
)
1601 int kill(pid_t
, int);
1602 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1603 int sigaddset(sigset_t
*, int);
1604 int sigdelset(sigset_t
*, int);
1605 int sigemptyset(sigset_t
*);
1606 int sigfillset(sigset_t
*);
1607 int sigismember(const scope sigset_t
*, int);
1608 int sigpending(sigset_t
*);
1609 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1610 int sigsuspend(const scope sigset_t
*);
1611 int sigwait(const scope sigset_t
*, int*);
1613 else version (CRuntime_UClibc
)
1615 int kill(pid_t
, int);
1616 int sigaction(int, const scope sigaction_t
*, sigaction_t
*);
1617 int sigaddset(sigset_t
*, int);
1618 int sigdelset(sigset_t
*, int);
1619 int sigemptyset(sigset_t
*);
1620 int sigfillset(sigset_t
*);
1621 int sigismember(const scope sigset_t
*, int);
1622 int sigpending(sigset_t
*);
1623 int sigprocmask(int, const scope sigset_t
*, sigset_t
*);
1624 int sigsuspend(const scope sigset_t
*);
1625 int sigwait(const scope sigset_t
*, int*);
1629 static assert(false, "Unsupported platform");
1703 enum SIGVTALRM
= 26;
1707 else version (HPPA_Any
)
1713 enum SIGVTALRM
= 20;
1717 else version (MIPS_Any
)
1723 enum SIGVTALRM
= 28;
1727 else version (PPC_Any
)
1733 enum SIGVTALRM
= 26;
1737 else version (ARM_Any
)
1743 enum SIGVTALRM
= 26;
1747 else version (RISCV_Any
)
1753 enum SIGVTALRM
= 26;
1757 else version (SPARC_Any
)
1763 enum SIGVTALRM
= 26;
1767 else version (IBMZ_Any
)
1773 enum SIGVTALRM
= 26;
1777 else version (LoongArch64
)
1783 enum SIGVTALRM
= 26;
1788 static assert(0, "unimplemented");
1792 enum SA_ONSTACK
= 0x08000000;
1793 enum SA_RESETHAND
= 0x80000000;
1794 enum SA_RESTART
= 0x10000000;
1795 enum SA_SIGINFO
= 8;
1796 enum SA_NOCLDWAIT
= 0x10000;
1797 enum SA_NODEFER
= 0x40000000;
1801 enum SA_ONSTACK
= 0x08000000;
1802 enum SA_RESETHAND
= 0x80000000;
1803 enum SA_RESTART
= 0x10000000;
1804 enum SA_SIGINFO
= 4;
1805 enum SA_NOCLDWAIT
= 2;
1806 enum SA_NODEFER
= 0x40000000;
1809 enum SA_NOMASK
= SA_NODEFER
;
1810 enum SA_ONESHOT
= SA_RESETHAND
;
1811 enum SA_STACK
= SA_ONSTACK
;
1876 else version (Darwin
)
1882 enum SIGVTALRM
= 26;
1886 enum SA_ONSTACK
= 0x0001;
1887 enum SA_RESETHAND
= 0x0004;
1888 enum SA_RESTART
= 0x0002;
1889 enum SA_SIGINFO
= 0x0040;
1890 enum SA_NOCLDWAIT
= 0x0020;
1891 enum SA_NODEFER
= 0x0010;
1893 enum ILL_ILLOPC
= 1;
1894 enum ILL_ILLOPN
= 4;
1895 enum ILL_ILLADR
= 5;
1896 enum ILL_ILLTRP
= 2;
1897 enum ILL_PRVOPC
= 3;
1898 enum ILL_PRVREG
= 6;
1899 enum ILL_COPROC
= 7;
1900 enum ILL_BADSTK
= 8;
1902 enum FPE_INTDIV
= 7;
1903 enum FPE_INTOVF
= 8;
1904 enum FPE_FLTDIV
= 1;
1905 enum FPE_FLTOVF
= 2;
1906 enum FPE_FLTUND
= 3;
1907 enum FPE_FLTRES
= 4;
1908 enum FPE_FLTINV
= 5;
1909 enum FPE_FLTSUB
= 6;
1950 else version (FreeBSD
)
1952 // No SIGPOLL on *BSD
1956 enum SIGVTALRM
= 26;
1962 SA_ONSTACK
= 0x0001,
1963 SA_RESTART
= 0x0002,
1964 SA_RESETHAND
= 0x0004,
1965 SA_NODEFER
= 0x0010,
1966 SA_NOCLDWAIT
= 0x0020,
1967 SA_SIGINFO
= 0x0040,
2033 else version (NetBSD
)
2035 // No SIGPOLL on *BSD
2039 enum SIGVTALRM
= 26;
2045 SA_ONSTACK
= 0x0001,
2046 SA_RESTART
= 0x0002,
2047 SA_RESETHAND
= 0x0004,
2048 SA_NODEFER
= 0x0010,
2049 SA_NOCLDWAIT
= 0x0020,
2050 SA_SIGINFO
= 0x0040,
2116 else version (OpenBSD
)
2118 // No SIGPOLL on *BSD
2122 enum SIGVTALRM
= 26;
2128 SA_ONSTACK
= 0x0001,
2129 SA_RESTART
= 0x0002,
2130 SA_RESETHAND
= 0x0004,
2131 SA_NODEFER
= 0x0010,
2132 SA_NOCLDWAIT
= 0x0020,
2133 SA_SIGINFO
= 0x0040,
2146 NSIGILL
= ILL_BADSTK
,
2154 NSIGBUS
= BUS_OBJERR
,
2161 NSIGSEGV
= SEGV_ACCERR
,
2174 NSIGFPE
= FPE_FLTSUB
,
2181 NSIGTRAP
= TRAP_TRACE
,
2192 NSIGCLD
= CLD_CONTINUED
,
2203 NSIGPOLL
= POLL_HUP
,
2206 else version (DragonFlyBSD
)
2208 // No SIGPOLL on *BSD
2212 enum SIGVTALRM
= 26;
2218 SA_ONSTACK
= 0x0001,
2219 SA_RESTART
= 0x0002,
2220 SA_RESETHAND
= 0x0004,
2221 SA_NODEFER
= 0x0010,
2222 SA_NOCLDWAIT
= 0x0020,
2223 SA_SIGINFO
= 0x0040,
2289 else version (Solaris
)
2292 enum SIGIO
= SIGPOLL
;
2296 enum SIGVTALRM
= 28;
2302 SA_ONSTACK
= 0x00001,
2303 SA_RESTART
= 0x00004,
2304 SA_RESETHAND
= 0x00002,
2305 SA_NODEFER
= 0x00010,
2306 SA_NOCLDWAIT
= 0x10000,
2307 SA_SIGINFO
= 0x00008,
2380 static assert(false, "Unsupported platform");
2389 ucontext_t // from ucontext
2390 mcontext_t // from ucontext
2405 sigfn_t bsd_signal(int sig, sigfn_t func);
2406 sigfn_t sigset(int sig, sigfn_t func);
2408 int killpg(pid_t, int);
2409 int sigaltstack(const scope stack_t*, stack_t*);
2412 int siginterrupt(int, int);
2417 version (CRuntime_Glibc
)
2419 enum SS_ONSTACK
= 1;
2420 enum SS_DISABLE
= 2;
2421 enum MINSIGSTKSZ
= 2048;
2422 enum SIGSTKSZ
= 8192;
2424 //ucontext_t (defined in core.sys.posix.ucontext)
2425 //mcontext_t (defined in core.sys.posix.ucontext)
2452 sigfn_t
bsd_signal(int sig
, sigfn_t func
);
2453 sigfn_t
sigset(int sig
, sigfn_t func
);
2457 sigfn_t2
bsd_signal(int sig
, sigfn_t2 func
);
2458 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2460 int killpg(pid_t
, int);
2461 int sigaltstack(const scope stack_t
*, stack_t
*);
2464 int siginterrupt(int, int);
2468 else version (Darwin
)
2470 enum SS_ONSTACK
= 0x0001;
2471 enum SS_DISABLE
= 0x0004;
2472 enum MINSIGSTKSZ
= 32768;
2473 enum SIGSTKSZ
= 131072;
2475 //ucontext_t (defined in core.sys.posix.ucontext)
2476 //mcontext_t (defined in core.sys.posix.ucontext)
2491 sigfn_t
bsd_signal(int sig
, sigfn_t func
);
2492 sigfn_t
sigset(int sig
, sigfn_t func
);
2496 sigfn_t2
bsd_signal(int sig
, sigfn_t2 func
);
2497 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2499 int killpg(pid_t
, int);
2500 int sigaltstack(const scope stack_t
*, stack_t
*);
2503 int siginterrupt(int, int);
2507 else version (FreeBSD
)
2511 SS_ONSTACK
= 0x0001,
2512 SS_DISABLE
= 0x0004,
2515 enum MINSIGSTKSZ
= 512 * 4;
2516 enum SIGSTKSZ
= (MINSIGSTKSZ
+ 32768);
2518 //ucontext_t (defined in core.sys.posix.ucontext)
2519 //mcontext_t (defined in core.sys.posix.ucontext)
2534 //sigfn_t bsd_signal(int sig, sigfn_t func);
2535 sigfn_t
sigset(int sig
, sigfn_t func
);
2539 //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
2540 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2542 int killpg(pid_t
, int);
2543 int sigaltstack(const scope stack_t
*, stack_t
*);
2546 int siginterrupt(int, int);
2550 else version (NetBSD
)
2554 SS_ONSTACK
= 0x0001,
2555 SS_DISABLE
= 0x0004,
2558 enum MINSIGSTKSZ
= 8192;
2559 enum SIGSTKSZ
= (MINSIGSTKSZ
+ 32768);
2561 //ucontext_t (defined in core.sys.posix.ucontext)
2562 //mcontext_t (defined in core.sys.posix.ucontext)
2577 //sigfn_t bsd_signal(int sig, sigfn_t func);
2578 sigfn_t
sigset(int sig
, sigfn_t func
);
2582 //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
2583 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2585 int killpg(pid_t
, int);
2586 int sigaltstack(const scope stack_t
*, stack_t
*);
2589 int siginterrupt(int, int);
2593 else version (OpenBSD
)
2597 SS_ONSTACK
= 0x0001,
2598 SS_DISABLE
= 0x0004,
2601 enum MINSIGSTKSZ
= 8192;
2602 enum SIGSTKSZ
= (MINSIGSTKSZ
+ 32768);
2604 //ucontext_t (defined in core.sys.posix.ucontext)
2605 //mcontext_t (defined in core.sys.posix.ucontext)
2616 int killpg(pid_t
, int);
2617 int sigaltstack(const scope stack_t
*, stack_t
*);
2618 int siginterrupt(int, int);
2621 else version (DragonFlyBSD
)
2625 SS_ONSTACK
= 0x0001,
2626 SS_DISABLE
= 0x0004,
2629 enum MINSIGSTKSZ
= 8192;
2630 enum SIGSTKSZ
= (MINSIGSTKSZ
+ 32768);
2632 //ucontext_t (defined in core.sys.posix.ucontext)
2633 //mcontext_t (defined in core.sys.posix.ucontext)
2648 //sigfn_t bsd_signal(int sig, sigfn_t func);
2649 sigfn_t
sigset(int sig
, sigfn_t func
);
2653 //sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
2654 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2656 int killpg(pid_t
, int);
2657 int sigaltstack(const scope stack_t
*, stack_t
*);
2660 int siginterrupt(int, int);
2664 else version (Solaris
)
2668 SS_ONSTACK
= 0x0001,
2669 SS_DISABLE
= 0x0002,
2672 enum MINSIGSTKSZ
= 2048;
2673 enum SIGSTKSZ
= 8192;
2688 sigfn_t
sigset(int sig
, sigfn_t func
);
2692 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2694 int killpg(pid_t
, int);
2695 int sigaltstack(const scope stack_t
*, stack_t
*);
2698 int siginterrupt(int, int);
2702 else version (CRuntime_Bionic
)
2704 enum SS_ONSTACK
= 1;
2705 enum SS_DISABLE
= 2;
2706 enum MINSIGSTKSZ
= 2048;
2707 enum SIGSTKSZ
= 8192;
2716 sigfn_t
bsd_signal(int, sigfn_t
);
2720 sigfn_t2
bsd_signal(int, sigfn_t2
);
2722 int killpg(int, int);
2723 int sigaltstack(const scope stack_t
*, stack_t
*);
2724 int siginterrupt(int, int);
2726 else version (CRuntime_Musl
)
2728 enum SS_ONSTACK
= 1;
2729 enum SS_DISABLE
= 2;
2733 enum MINSIGSTKSZ
= 2048;
2734 enum SIGSTKSZ
= 8192;
2736 else version (AArch64
)
2738 enum MINSIGSTKSZ
= 6144;
2739 enum SIGSTKSZ
= 12288;
2741 else version (IBMZ_Any
)
2743 enum MINSIGSTKSZ
= 4096;
2744 enum SIGSTKSZ
= 10240;
2746 else version (MIPS_Any
)
2748 enum MINSIGSTKSZ
= 2048;
2749 enum SIGSTKSZ
= 8192;
2751 else version (PPC_Any
)
2753 enum MINSIGSTKSZ
= 4096;
2754 enum SIGSTKSZ
= 10240;
2756 else version (X86_Any
)
2758 enum MINSIGSTKSZ
= 2048;
2759 enum SIGSTKSZ
= 8192;
2762 static assert(0, "unimplemented");
2764 //ucontext_t (defined in core.sys.posix.ucontext)
2765 //mcontext_t (defined in core.sys.posix.ucontext)
2786 sigfn_t
bsd_signal(int sig
, sigfn_t func
);
2787 sigfn_t
sigset(int sig
, sigfn_t func
);
2791 sigfn_t2
bsd_signal(int sig
, sigfn_t2 func
);
2792 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2794 int killpg(pid_t
, int);
2795 int sigaltstack(const scope stack_t
*, stack_t
*);
2798 int siginterrupt(int, int);
2802 else version (CRuntime_UClibc
)
2804 enum SS_ONSTACK
= 1;
2805 enum SS_DISABLE
= 2;
2806 enum MINSIGSTKSZ
= 2048;
2807 enum SIGSTKSZ
= 8192;
2834 sigfn_t
sigset(int sig
, sigfn_t func
);
2838 sigfn_t2
sigset(int sig
, sigfn_t2 func
);
2840 int killpg(pid_t
, int);
2841 int sigaltstack(const scope stack_t
*, stack_t
*);
2844 int siginterrupt(int, int);
2850 static assert(false, "Unsupported platform");
2854 // Realtime Signals (RTS)
2862 void(*)(sigval) sigev_notify_function;
2863 pthread_attr_t* sigev_notify_attributes;
2872 private enum __SIGEV_MAX_SIZE
= 64;
2874 static if ( __WORDSIZE
== 64 )
2876 private enum __SIGEV_PAD_SIZE
= ((__SIGEV_MAX_SIZE
/ int.sizeof
) - 4);
2880 private enum __SIGEV_PAD_SIZE
= ((__SIGEV_MAX_SIZE
/ int.sizeof
) - 3);
2891 int[__SIGEV_PAD_SIZE
] _pad
;
2896 void function(sigval
) sigev_notify_function
;
2897 void* sigev_notify_attributes
;
2902 else version (FreeBSD
)
2914 void function(sigval
) sigev_notify_function
;
2915 void* sigev_notify_attributes
;
2917 c_long
[8] __spare__
;
2921 else version (NetBSD
)
2928 void function(sigval
) sigev_notify_function
;
2929 void /* pthread_attr_t */*sigev_notify_attributes
;
2932 else version (OpenBSD
)
2934 // OpenBSD does not implement sigevent.
2935 alias sigevent
= void;
2937 else version (DragonFlyBSD
)
2942 int sigev_notify_kqueue
;
2943 void /*pthread_attr_t*/ * sigev_notify_attributes
;
2955 _sigev_un_t sigev_un
;
2956 _sigval_t sigev_value
;
2957 void function(_sigval_t
) sigev_notify_function
;
2960 else version (Darwin
)
2967 void function(sigval
) sigev_notify_function
;
2968 pthread_attr_t
* sigev_notify_attributes
;
2971 else version (Solaris
)
2978 void function(sigval
) sigev_notify_function
;
2979 pthread_attr_t
* sigev_notify_attributes
;
2985 static assert(false, "Unsupported platform");
2989 int sigqueue(pid_t, int, const sigval);
2990 int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
2991 int sigwaitinfo(const scope sigset_t*, siginfo_t*);
2997 version (CRuntime_Glibc
)
2999 int sigqueue(pid_t
, int, const sigval
);
3000 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3001 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3003 else version (FreeBSD
)
3005 int sigqueue(pid_t
, int, const sigval
);
3006 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3007 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3009 else version (NetBSD
)
3011 int sigqueue(pid_t
, int, const sigval
);
3012 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3013 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3015 else version (OpenBSD
)
3018 else version (DragonFlyBSD
)
3020 int sigqueue(pid_t
, int, const sigval
);
3021 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3022 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3024 else version (Darwin
)
3027 else version (Solaris
)
3029 int sigqueue(pid_t
, int, const sigval
);
3030 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3031 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3033 else version (CRuntime_Bionic
)
3036 else version (CRuntime_Musl
)
3038 int sigqueue(pid_t
, int, const sigval
);
3039 pragma(mangle
, muslRedirTime64Mangle
!("sigtimedwait", "__sigtimedwait_time64"))
3040 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3041 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3043 else version (CRuntime_UClibc
)
3045 int sigqueue(pid_t
, int, const sigval
);
3046 int sigtimedwait(const scope sigset_t
*, siginfo_t
*, const scope timespec
*);
3047 int sigwaitinfo(const scope sigset_t
*, siginfo_t
*);
3051 static assert(false, "Unsupported platform");
3058 int pthread_kill(pthread_t, int);
3059 int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
3062 version (CRuntime_Glibc
)
3064 int pthread_kill(pthread_t
, int);
3065 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3067 else version (Darwin
)
3069 int pthread_kill(pthread_t
, int);
3070 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3072 else version (FreeBSD
)
3074 int pthread_kill(pthread_t
, int);
3075 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3077 else version (NetBSD
)
3079 int pthread_kill(pthread_t
, int);
3080 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3082 else version (OpenBSD
)
3084 int pthread_kill(pthread_t
, int);
3085 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3087 else version (DragonFlyBSD
)
3089 int pthread_kill(pthread_t
, int);
3090 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3092 else version (Solaris
)
3094 int pthread_kill(pthread_t
, int);
3095 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3097 else version (CRuntime_Bionic
)
3099 int pthread_kill(pthread_t
, int);
3100 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3102 else version (CRuntime_Musl
)
3104 int pthread_kill(pthread_t
, int);
3105 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3107 else version (CRuntime_UClibc
)
3109 int pthread_kill(pthread_t
, int);
3110 int pthread_sigmask(int, const scope sigset_t
*, sigset_t
*);
3111 int pthread_sigqueue(pthread_t
, int, sigval
);
3115 static assert(false, "Unsupported platform");