diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-10-01 15:57:38 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-10-01 13:58:58 -0400 |
| commit | 17f2af10b56dd508ebd4a22834fd594cb5a49864 (patch) | |
| tree | 38da45089fee93cf06ff7753eae768c922b5fdab /lib/std/os/linux.zig | |
| parent | bed4bfa69ad57595e4595caa96653d9241a8dc2e (diff) | |
| download | zig-17f2af10b56dd508ebd4a22834fd594cb5a49864.tar.gz zig-17f2af10b56dd508ebd4a22834fd594cb5a49864.zip | |
Correct signal bits for MIPS
Also enable the segfault handler for all the supported architectures
beside MIPS.
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 11 |
1 files changed, 7 insertions, 4 deletions
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; } |
