| ... | ... | @@ -949,14 +949,11 @@ test "sigset_t bits" { |
| 949 | 949 | if (native_os == .wasi or native_os == .windows) |
| 950 | 950 | return error.SkipZigTest; |
| 951 | 951 | |
| 952 | | if (true) { |
| 953 | | // https://github.com/ziglang/zig/issues/24380 |
| 954 | | return error.SkipZigTest; |
| 955 | | } |
| 952 | const NO_SIG: i32 = 0; |
| 956 | 953 | |
| 957 | 954 | const S = struct { |
| 958 | 955 | var expected_sig: i32 = undefined; |
| 959 | | var handler_called_count: u32 = 0; |
| 956 | var seen_sig: i32 = NO_SIG; |
| 960 | 957 | |
| 961 | 958 | fn handler(sig: i32, info: *const posix.siginfo_t, ctx_ptr: ?*anyopaque) callconv(.c) void { |
| 962 | 959 | _ = ctx_ptr; |
| ... | ... | @@ -965,23 +962,25 @@ test "sigset_t bits" { |
| 965 | 962 | .netbsd => info.info.signo, |
| 966 | 963 | else => info.signo, |
| 967 | 964 | }; |
| 968 | | if (sig == expected_sig and sig == info_sig) { |
| 969 | | handler_called_count += 1; |
| 965 | if (seen_sig == NO_SIG and sig == expected_sig and sig == info_sig) { |
| 966 | seen_sig = sig; |
| 970 | 967 | } |
| 971 | 968 | } |
| 972 | 969 | }; |
| 973 | 970 | |
| 974 | | const self_pid = posix.system.getpid(); |
| 971 | // Assume this is a single-threaded process where the current thread has the |
| 972 | // 'pid' thread id. (The sigprocmask calls are thread-private state.) |
| 973 | const self_tid = posix.system.getpid(); |
| 975 | 974 | |
| 976 | 975 | // To check that sigset_t mapping matches kernel (think u32/u64 mismatches on |
| 977 | 976 | // big-endian), try sending a blocked signal to make sure the mask matches the |
| 978 | 977 | // signal. (Send URG and CHLD because they're ignored by default in the |
| 979 | 978 | // debugger, vs. USR1 or other named signals) |
| 980 | | inline for ([_]usize{ posix.SIG.URG, posix.SIG.CHLD, 62, 94, 126 }) |test_signo| { |
| 979 | inline for ([_]i32{ posix.SIG.URG, posix.SIG.CHLD, 62, 94, 126 }) |test_signo| { |
| 981 | 980 | if (test_signo >= posix.NSIG) continue; |
| 982 | 981 | |
| 983 | 982 | S.expected_sig = test_signo; |
| 984 | | S.handler_called_count = 0; |
| 983 | S.seen_sig = NO_SIG; |
| 985 | 984 | |
| 986 | 985 | const sa: posix.Sigaction = .{ |
| 987 | 986 | .handler = .{ .sigaction = &S.handler }, |
| ... | ... | @@ -1001,18 +1000,18 @@ test "sigset_t bits" { |
| 1001 | 1000 | |
| 1002 | 1001 | // qemu maps target signals to host signals 1-to-1, so targets |
| 1003 | 1002 | // with more signals than the host will fail to send the signal. |
| 1004 | | const rc = posix.system.kill(self_pid, test_signo); |
| 1003 | const rc = posix.system.kill(self_tid, test_signo); |
| 1005 | 1004 | switch (posix.errno(rc)) { |
| 1006 | 1005 | .SUCCESS => { |
| 1007 | 1006 | // See that the signal is blocked, then unblocked |
| 1008 | | try testing.expectEqual(0, S.handler_called_count); |
| 1007 | try testing.expectEqual(NO_SIG, S.seen_sig); |
| 1009 | 1008 | posix.sigprocmask(posix.SIG.UNBLOCK, &block_one, null); |
| 1010 | | try testing.expectEqual(1, S.handler_called_count); |
| 1009 | try testing.expectEqual(test_signo, S.seen_sig); |
| 1011 | 1010 | }, |
| 1012 | 1011 | .INVAL => { |
| 1013 | 1012 | // Signal won't get delviered. Just clean up. |
| 1014 | 1013 | posix.sigprocmask(posix.SIG.UNBLOCK, &block_one, null); |
| 1015 | | try testing.expectEqual(0, S.handler_called_count); |
| 1014 | try testing.expectEqual(NO_SIG, S.seen_sig); |
| 1016 | 1015 | }, |
| 1017 | 1016 | else => |errno| return posix.unexpectedErrno(errno), |
| 1018 | 1017 | } |