std.os.linux: block all signals in raise

This commit is contained in:
Misaki Kasumi 2025-04-02 18:36:40 +08:00 committed by Alex Rønne Petersen
parent 06fc600aec
commit d128f5c0bb
No known key found for this signature in database

View file

@ -722,9 +722,12 @@ 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;
// block application signals
sigprocmask(SIG.BLOCK, &linux.app_mask, &set);
sigprocmask(SIG.BLOCK, &linux.all_mask, &set);
const tid = linux.gettid();
const rc = linux.tkill(tid, sig);