diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 12a71df6a5..dc64f6b4bd 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -720,9 +720,19 @@ pub fn raise(sig: u8) RaiseError!void { } if (native_os == .linux) { + // https://git.musl-libc.org/cgit/musl/commit/?id=0bed7e0acfd34e3fb63ca0e4d99b7592571355a9 + // + // Unlike musl, libc-less Zig std does not have any internal signals for implementation purposes, so we + // need to block all signals on the assumption that any of them could potentially fork() in a handler. + var set: sigset_t = undefined; + sigprocmask(SIG.BLOCK, &linux.all_mask, &set); + const tid = linux.gettid(); const rc = linux.tkill(tid, sig); + // restore signal mask + sigprocmask(SIG.SETMASK, &set, null); + switch (errno(rc)) { .SUCCESS => return, else => |err| return unexpectedErrno(err),