diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-23 11:49:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-23 11:49:43 -0700 |
| commit | 718f8d531488866ff3623c83e05d8ad9a8f72659 (patch) | |
| tree | c75598db53f62ca4f75a11319998536eed5ac0db /lib/std/debug.zig | |
| parent | e8503ecb6552087d6954423e59f3dfa8ca4a1b09 (diff) | |
| parent | 2cced8903e07066a724a81257dadae233dd5893f (diff) | |
| download | zig-718f8d531488866ff3623c83e05d8ad9a8f72659.tar.gz zig-718f8d531488866ff3623c83e05d8ad9a8f72659.zip | |
Merge pull request #20706 from alexrp/sigaction-nosys
`std.posix`: Make `sigaction()` infallible
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 4fd041df98..a6bc929cfd 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -2601,11 +2601,11 @@ pub fn maybeEnableSegfaultHandler() void { var windows_segfault_handle: ?windows.HANDLE = null; -pub fn updateSegfaultHandler(act: ?*const posix.Sigaction) error{OperationNotSupported}!void { - try posix.sigaction(posix.SIG.SEGV, act, null); - try posix.sigaction(posix.SIG.ILL, act, null); - try posix.sigaction(posix.SIG.BUS, act, null); - try posix.sigaction(posix.SIG.FPE, act, null); +pub fn updateSegfaultHandler(act: ?*const posix.Sigaction) void { + posix.sigaction(posix.SIG.SEGV, act, null); + posix.sigaction(posix.SIG.ILL, act, null); + posix.sigaction(posix.SIG.BUS, act, null); + posix.sigaction(posix.SIG.FPE, act, null); } /// Attaches a global SIGSEGV handler which calls `@panic("segmentation fault");` @@ -2623,9 +2623,7 @@ pub fn attachSegfaultHandler() void { .flags = (posix.SA.SIGINFO | posix.SA.RESTART | posix.SA.RESETHAND), }; - updateSegfaultHandler(&act) catch { - @panic("unable to install segfault handler, maybe adjust have_segfault_handling_support in std/debug.zig"); - }; + updateSegfaultHandler(&act); } fn resetSegfaultHandler() void { @@ -2641,8 +2639,7 @@ fn resetSegfaultHandler() void { .mask = posix.empty_sigset, .flags = 0, }; - // To avoid a double-panic, do nothing if an error happens here. - updateSegfaultHandler(&act) catch {}; + updateSegfaultHandler(&act); } fn handleSegfaultPosix(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.C) noreturn { |
