authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-02 17:36:59+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-04-02 17:36:59+02:00
log9dfdf3503242428f93c56c8f211834bd6b87ac76
treee114b0d6a212a773e67bc7f0a308a0c4f0fbcf8a
parent4303b43519fe8a3b21a264642076d30c2f0927bc
parentaa832d6a6dbde8a0753d6aa59cc8199b009ea260
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #22337 from ruihe774/fix-app-mask

* std.os.linux: remove app_mask * std.posix: on libc-less linux, block all signals in raise(), not just app_mask

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

lib/std/os/linux.zig-1
......@@ -5151,7 +5151,6 @@ pub const NSIG = if (is_mips) 128 else 65;
51515151pub const sigset_t = [1024 / 32]u32;
51525152
51535153pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len;
5154pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
51555154
51565155const k_sigaction_funcs = struct {
51575156 const handler = ?*align(1) const fn (i32) callconv(.c) void;
lib/std/posix.zig+5-2
......@@ -724,9 +724,12 @@ pub fn raise(sig: u8) RaiseError!void {
724724 }
725725
726726 if (native_os == .linux) {
727 // https://git.musl-libc.org/cgit/musl/commit/?id=0bed7e0acfd34e3fb63ca0e4d99b7592571355a9
728 //
729 // Unlike musl, libc-less Zig std does not have any internal signals for implementation purposes, so we
730 // need to block all signals on the assumption that any of them could potentially fork() in a handler.
727731 var set: sigset_t = undefined;
728 // block application signals
729 sigprocmask(SIG.BLOCK, &linux.app_mask, &set);
732 sigprocmask(SIG.BLOCK, &linux.all_mask, &set);
730733
731734 const tid = linux.gettid();
732735 const rc = linux.tkill(tid, sig);