Signal types
pub const SIG = switch (native_os)
pub const SIG = switch (native_os) {
.linux => linux.SIG,
.emscripten => emscripten.SIG,
.windows => enum(u32) {
/// interrupt
INT = 2,
/// illegal instruction - invalid function image
ILL = 4,
/// floating point exception
FPE = 8,
/// segment violation
SEGV = 11,
/// Software termination signal from kill
TERM = 15,
/// Ctrl-Break sequence
BREAK = 21,
/// abnormal termination triggered by abort call
ABRT = 22,
/// SIGABRT compatible with other platforms, same as SIGABRT
ABRT_COMPAT = 6,
_,
// Signal action codes
/// default signal action
pub const DFL = 0;
/// ignore signal
pub const IGN = 1;
/// return current value
pub const GET = 2;
/// signal gets error
pub const SGE = 3;
/// acknowledge
pub const ACK = 4;
/// Signal error value (returned by signal call on error)
pub const ERR = -1;
},
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => enum(u32) {
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(5);
/// block specified signal set
pub const BLOCK = 1;
/// unblock specified signal set
pub const UNBLOCK = 2;
/// set specified signal set
pub const SETMASK = 3;
pub const IOT: SIG = .ABRT;
pub const POLL: SIG = .EMT;
/// hangup
HUP = 1,
/// interrupt
INT = 2,
/// quit
QUIT = 3,
/// illegal instruction (not reset when caught)
ILL = 4,
/// trace trap (not reset when caught)
TRAP = 5,
/// abort()
ABRT = 6,
/// EMT instruction
EMT = 7,
/// floating point exception
FPE = 8,
/// kill (cannot be caught or ignored)
KILL = 9,
/// bus error
BUS = 10,
/// segmentation violation
SEGV = 11,
/// bad argument to system call
SYS = 12,
/// write on a pipe with no one to read it
PIPE = 13,
/// alarm clock
ALRM = 14,
/// software termination signal from kill
TERM = 15,
/// urgent condition on IO channel
URG = 16,
/// sendable stop signal not from tty
STOP = 17,
/// stop signal from tty
TSTP = 18,
/// continue a stopped process
CONT = 19,
/// to parent on child stop or exit
CHLD = 20,
/// to readers pgrp upon background tty read
TTIN = 21,
/// like TTIN for output if (tp->t_local<OSTOP)
TTOU = 22,
/// input/output possible signal
IO = 23,
/// exceeded CPU time limit
XCPU = 24,
/// exceeded file size limit
XFSZ = 25,
/// virtual time alarm
VTALRM = 26,
/// profiling time alarm
PROF = 27,
/// window size changes
WINCH = 28,
/// information request
INFO = 29,
/// user defined signal 1
USR1 = 30,
/// user defined signal 2
USR2 = 31,
_,
},
.freebsd => enum(u32) {
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const WORDS = 4;
pub const MAXSIG = 128;
pub inline fn IDX(sig: usize) usize {
return sig - 1;
}
pub inline fn WORD(sig: usize) usize {
return IDX(sig) >> 5;
}
pub inline fn BIT(sig: usize) usize {
return 1 << (IDX(sig) & 31);
}
pub inline fn VALID(sig: usize) usize {
return sig <= MAXSIG and sig > 0;
}
pub const IOT: SIG = .ABRT;
pub const LWP: SIG = .THR;
pub const RTMIN = 65;
pub const RTMAX = 126;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
INFO = 29,
USR1 = 30,
USR2 = 31,
THR = 32,
LIBRT = 33,
_,
},
.illumos => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(2);
pub const WORDS = 4;
pub const MAXSIG = 75;
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const RTMIN = 42;
pub const RTMAX = 74;
pub inline fn IDX(sig: usize) usize {
return sig - 1;
}
pub inline fn WORD(sig: usize) usize {
return IDX(sig) >> 5;
}
pub inline fn BIT(sig: usize) usize {
return 1 << (IDX(sig) & 31);
}
pub inline fn VALID(sig: usize) usize {
return sig <= MAXSIG and sig > 0;
}
pub const POLL: SIG = .IO;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
IOT = 6,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
USR1 = 16,
USR2 = 17,
CLD = 18,
CHLD = 18,
PWR = 19,
WINCH = 20,
URG = 21,
IO = 22,
STOP = 23,
TSTP = 24,
CONT = 25,
TTIN = 26,
TTOU = 27,
VTALRM = 28,
PROF = 29,
XCPU = 30,
XFSZ = 31,
WAITING = 32,
LWP = 33,
FREEZE = 34,
THAW = 35,
CANCEL = 36,
LOST = 37,
XRES = 38,
JVM1 = 39,
JVM2 = 40,
INFO = 41,
_,
},
.netbsd => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const WORDS = 4;
pub const MAXSIG = 128;
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const RTMIN = 33;
pub const RTMAX = 63;
pub inline fn IDX(sig: usize) usize {
return sig - 1;
}
pub inline fn WORD(sig: usize) usize {
return IDX(sig) >> 5;
}
pub inline fn BIT(sig: usize) usize {
return 1 << (IDX(sig) & 31);
}
pub inline fn VALID(sig: usize) usize {
return sig <= MAXSIG and sig > 0;
}
pub const IOT: SIG = .ABRT;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
INFO = 29,
USR1 = 30,
USR2 = 31,
PWR = 32,
_,
},
.dragonfly => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const WORDS = 4;
pub const IOT: SIG = .ABRT;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
INFO = 29,
USR1 = 30,
USR2 = 31,
THR = 32,
CKPT = 33,
CKPTEXIT = 34,
_,
},
.haiku => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3);
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const IOT: SIG = .ABRT;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
CHLD = 5,
ABRT = 6,
PIPE = 7,
FPE = 8,
KILL = 9,
STOP = 10,
SEGV = 11,
CONT = 12,
TSTP = 13,
ALRM = 14,
TERM = 15,
TTIN = 16,
TTOU = 17,
USR1 = 18,
USR2 = 19,
WINCH = 20,
KILLTHR = 21,
TRAP = 22,
POLL = 23,
PROF = 24,
SYS = 25,
URG = 26,
VTALRM = 27,
XCPU = 28,
XFSZ = 29,
BUS = 30,
RESERVED1 = 31,
RESERVED2 = 32,
_,
},
.openbsd => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const CATCH: ?Sigaction.handler_fn = @ptrFromInt(2);
pub const HOLD: ?Sigaction.handler_fn = @ptrFromInt(3);
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
pub const IOT: SIG = .ABRT;
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
INFO = 29,
USR1 = 30,
USR2 = 31,
PWR = 32,
_,
},
// https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal.h
// https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h
.serenity => enum(u32) {
pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0);
pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize));
pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1);
pub const BLOCK = 1;
pub const UNBLOCK = 2;
pub const SETMASK = 3;
INVAL = 0,
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
BUS = 7,
FPE = 8,
KILL = 9,
USR1 = 10,
SEGV = 11,
USR2 = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
STKFLT = 16,
CHLD = 17,
CONT = 18,
STOP = 19,
TSTP = 20,
TTIN = 21,
TTOU = 22,
URG = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
IO = 29,
INFO = 30,
SYS = 31,
CANCEL = 32,
_,
},
else => void,
}