| author | |
| committer | |
| log | fc70db5ab5ab252471cf35acd48dc8dea0b0870d |
| tree | d5389b17b4ccb7bba2c6710061c17111187e0306 |
| parent | 629cc6cf285f60581f03b69ec8d012d2e370a029 |
Xnu's sigaction() only supports fetching a limited set of sa_flags, test
SA_SIGINFO instead of SA_RESETHAND as that's supported everywhere.
Add another check to make sure SA_RESETHAND works.
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>2 files changed, 9 insertions(+), 1 deletions(-)
lib/std/os/bits/darwin.zig+5| ... | ... | @@ -126,6 +126,11 @@ pub const timespec = extern struct { |
| 126 | 126 | pub const sigset_t = u32; |
| 127 | 127 | pub const empty_sigset: sigset_t = 0; |
| 128 | 128 | |
| 129 | pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize)); | |
| 130 | pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0); | |
| 131 | pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1); | |
| 132 | pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5); | |
| 133 | ||
| 129 | 134 | pub const siginfo_t = extern struct { |
| 130 | 135 | signo: c_int, |
| 131 | 136 | errno: c_int, |
lib/std/os/test.zig+4-1| ... | ... | @@ -672,8 +672,11 @@ test "sigaction" { |
| 672 | 672 | // Check that we can read it back correctly. |
| 673 | 673 | os.sigaction(os.SIGUSR1, null, &old_sa); |
| 674 | 674 | testing.expectEqual(S.handler, old_sa.handler.sigaction.?); |
| 675 | testing.expect((old_sa.flags & os.SA_RESETHAND) != 0); | |
| 675 | testing.expect((old_sa.flags & os.SA_SIGINFO) != 0); | |
| 676 | 676 | // Invoke the handler. |
| 677 | 677 | try os.raise(os.SIGUSR1); |
| 678 | 678 | testing.expect(signal_test_failed == false); |
| 679 | // Check if the handler has been correctly reset to SIG_DFL | |
| 680 | os.sigaction(os.SIGUSR1, null, &old_sa); | |
| 681 | testing.expectEqual(os.SIG_DFL, old_sa.handler.sigaction); | |
| 679 | 682 | } |