From 17f2af10b56dd508ebd4a22834fd594cb5a49864 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 1 Oct 2019 15:57:38 +0200 Subject: Correct signal bits for MIPS Also enable the segfault handler for all the supported architectures beside MIPS. --- lib/std/os/linux.zig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/std/os/linux.zig') diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 9550518842..e813519c68 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -673,15 +673,18 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti assert(sig >= 1); assert(sig != SIGKILL); assert(sig != SIGSTOP); + + const restorer_fn = if ((act.flags & SA_SIGINFO) != 0) restore_rt else restore; var ksa = k_sigaction{ .sigaction = act.sigaction, .flags = act.flags | SA_RESTORER, .mask = undefined, - .restorer = @ptrCast(extern fn () void, restore_rt), + .restorer = @ptrCast(extern fn () void, restorer_fn), }; var ksa_old: k_sigaction = undefined; - @memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), 8); - const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), @sizeOf(@typeOf(ksa.mask))); + const ksa_mask_size = @sizeOf(@typeOf(ksa_old.mask)); + @memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), ksa_mask_size); + const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size); const err = getErrno(result); if (err != 0) { return result; @@ -689,7 +692,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti if (oact) |old| { old.sigaction = ksa_old.sigaction; old.flags = @truncate(u32, ksa_old.flags); - @memcpy(@ptrCast([*]u8, &old.mask), @ptrCast([*]const u8, &ksa_old.mask), @sizeOf(@typeOf(ksa_old.mask))); + @memcpy(@ptrCast([*]u8, &old.mask), @ptrCast([*]const u8, &ksa_old.mask), ksa_mask_size); } return 0; } -- cgit v1.2.3