authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-13 19:17:04+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-13 19:17:04+01:00
logfc70db5ab5ab252471cf35acd48dc8dea0b0870d
treed5389b17b4ccb7bba2c6710061c17111187e0306
parent629cc6cf285f60581f03b69ec8d012d2e370a029

std: Fixes for siginfo test on macos

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,6 +126,11 @@ pub const timespec = extern struct {
126pub const sigset_t = u32;126pub const sigset_t = u32;
127pub const empty_sigset: sigset_t = 0;127pub const empty_sigset: sigset_t = 0;
128128
129pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
130pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
131pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
132pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
133
129pub const siginfo_t = extern struct {134pub const siginfo_t = extern struct {
130 signo: c_int,135 signo: c_int,
131 errno: c_int,136 errno: c_int,
lib/std/os/test.zig+4-1
...@@ -672,8 +672,11 @@ test "sigaction" {...@@ -672,8 +672,11 @@ test "sigaction" {
672 // Check that we can read it back correctly.672 // Check that we can read it back correctly.
673 os.sigaction(os.SIGUSR1, null, &old_sa);673 os.sigaction(os.SIGUSR1, null, &old_sa);
674 testing.expectEqual(S.handler, old_sa.handler.sigaction.?);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 // Invoke the handler.676 // Invoke the handler.
677 try os.raise(os.SIGUSR1);677 try os.raise(os.SIGUSR1);
678 testing.expect(signal_test_failed == false);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}