commit 9dfdf3503242428f93c56c8f211834bd6b87ac76 (tree)
parent 4303b43519fe8a3b21a264642076d30c2f0927bc
Author: Alex Rønne Petersen <alex@alexrp.com>
Date: Wed, 2 Apr 2025 17:36:59 +0200
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
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
@@ -5151,7 +5151,6 @@ pub const NSIG = if (is_mips) 128 else 65;
pub const sigset_t = [1024 / 32]u32;
pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len;
-pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
const k_sigaction_funcs = struct {
const handler = ?*align(1) const fn (i32) callconv(.c) void;
diff --git a/lib/std/posix.zig b/lib/std/posix.zig
@@ -724,9 +724,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);