authorgravatar for misakikasumi@outlook.comMisaki Kasumi <misakikasumi@outlook.com> 2025-04-02 18:36:40+08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-02 23:57:32+02:00
logd128f5c0bb06b9485f37145e24bc99cbba27087c
tree8309ab978e4cbab3f5775b9be00e7bf6111378bc
parent06fc600aec227f00d1edbb0b1577b26e490c7d8c
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux: block all signals in raise


1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/posix.zig+5-2
...@@ -722,9 +722,12 @@ pub fn raise(sig: u8) RaiseError!void {...@@ -722,9 +722,12 @@ pub fn raise(sig: u8) RaiseError!void {
722 }722 }
723723
724 if (native_os == .linux) {724 if (native_os == .linux) {
725 // https://git.musl-libc.org/cgit/musl/commit/?id=0bed7e0acfd34e3fb63ca0e4d99b7592571355a9
726 //
727 // Unlike musl, libc-less Zig std does not have any internal signals for implementation purposes, so we
728 // need to block all signals on the assumption that any of them could potentially fork() in a handler.
725 var set: sigset_t = undefined;729 var set: sigset_t = undefined;
726 // block application signals730 sigprocmask(SIG.BLOCK, &linux.all_mask, &set);
727 sigprocmask(SIG.BLOCK, &linux.app_mask, &set);
728731
729 const tid = linux.gettid();732 const tid = linux.gettid();
730 const rc = linux.tkill(tid, sig);733 const rc = linux.tkill(tid, sig);