Function raise [src]
Prototype
pub fn raise(sig: u8) RaiseError!void
Parameters
sig: u8
Possible Errors
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub fn raise(sig: u8) RaiseError!void {
if (builtin.link_libc) {
switch (errno(system.raise(sig))) {
.SUCCESS => return,
else => |err| return unexpectedErrno(err),
}
}
if (native_os == .linux) {
// Block all signals so a `fork` (from a signal handler) between the gettid() and kill() syscalls
// cannot trigger an extra, unexpected, inter-process signal. Signal paranoia inherited from Musl.
const filled = linux.sigfillset();
var orig: sigset_t = undefined;
sigprocmask(SIG.BLOCK, &filled, &orig);
const rc = linux.tkill(linux.gettid(), sig);
sigprocmask(SIG.SETMASK, &orig, null);
switch (errno(rc)) {
.SUCCESS => return,
else => |err| return unexpectedErrno(err),
}
}
@compileError("std.posix.raise unimplemented for this target");
}