Source
pub const siginfo_t = switch (native_os) {
.linux => linux.siginfo_t,
.emscripten => emscripten.siginfo_t,
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
signo: c_int,
errno: c_int,
code: c_int,
pid: pid_t,
uid: uid_t,
status: c_int,
addr: *allowzero anyopaque,
value: extern union {
int: c_int,
ptr: *anyopaque,
},
si_band: c_long,
_pad: [7]c_ulong,
},
.freebsd => extern struct {
// Signal number.
signo: c_int,
// Errno association.
errno: c_int,
/// Signal code.
///
/// Cause of signal, one of the SI_ macros or signal-specific values, i.e.
/// one of the FPE_... values for SIGFPE.
/// This value is equivalent to the second argument to an old-style FreeBSD
/// signal handler.
code: c_int,
/// Sending process.
pid: pid_t,
/// Sender's ruid.
uid: uid_t,
/// Exit value.
status: c_int,
/// Faulting instruction.
addr: *allowzero anyopaque,
/// Signal value.
value: sigval,
reason: extern union {
fault: extern struct {
/// Machine specific trap code.
trapno: c_int,
},
timer: extern struct {
timerid: c_int,
overrun: c_int,
},
mesgq: extern struct {
mqd: c_int,
},
poll: extern struct {
/// Band event for SIGPOLL. UNUSED.
band: c_long,
},
spare: extern struct {
spare1: c_long,
spare2: [7]c_int,
},
},
},
.solaris, .illumos => extern struct {
signo: c_int,
code: c_int,
errno: c_int,
// 64bit architectures insert 4bytes of padding here, this is done by
// correctly aligning the reason field
reason: extern union {
proc: extern struct {
pid: pid_t,
pdata: extern union {
kill: extern struct {
uid: uid_t,
value: sigval_t,
},
cld: extern struct {
utime: clock_t,
status: c_int,
stime: clock_t,
},
},
contract: solaris.ctid_t,
zone: solaris.zoneid_t,
},
fault: extern struct {
addr: *allowzero anyopaque,
trapno: c_int,
pc: ?*anyopaque,
},
file: extern struct {
// fd not currently available for SIGPOLL.
fd: c_int,
band: c_long,
},
prof: extern struct {
addr: ?*anyopaque,
timestamp: timespec,
syscall: c_short,
sysarg: u8,
fault: u8,
args: [8]c_long,
state: [10]c_int,
},
rctl: extern struct {
entity: i32,
},
__pad: [256 - 4 * @sizeOf(c_int)]u8,
} align(@sizeOf(usize)),
comptime {
assert(@sizeOf(@This()) == 256);
assert(@alignOf(@This()) == @sizeOf(usize));
}
},
.netbsd => extern union {
pad: [128]u8,
info: netbsd._ksiginfo,
},
.dragonfly => extern struct {
signo: c_int,
errno: c_int,
code: c_int,
pid: c_int,
uid: uid_t,
status: c_int,
addr: *allowzero anyopaque,
value: sigval,
band: c_long,
__spare__: [7]c_int,
},
.haiku => extern struct {
signo: i32,
code: i32,
errno: i32,
pid: pid_t,
uid: uid_t,
addr: *allowzero anyopaque,
},
.openbsd => extern struct {
signo: c_int,
code: c_int,
errno: c_int,
data: extern union {
proc: extern struct {
pid: pid_t,
pdata: extern union {
kill: extern struct {
uid: uid_t,
value: sigval,
},
cld: extern struct {
utime: clock_t,
stime: clock_t,
status: c_int,
},
},
},
fault: extern struct {
addr: *allowzero anyopaque,
trapno: c_int,
},
__pad: [128 - 3 * @sizeOf(c_int)]u8,
},
comptime {
if (@sizeOf(usize) == 4)
assert(@sizeOf(@This()) == 128)
else
// Take into account the padding between errno and data fields.
assert(@sizeOf(@This()) == 136);
}
},
// https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L27-L37
.serenity => extern struct {
signo: c_int,
code: c_int,
errno: c_int,
pid: pid_t,
uid: uid_t,
addr: ?*anyopaque,
status: c_int,
band: c_int,
value: sigval,
},
else => void,
}