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>
This commit is contained in:
LemonBoy 2020-12-13 19:17:04 +01:00
parent 629cc6cf28
commit fc70db5ab5
2 changed files with 9 additions and 1 deletions

View File

@ -126,6 +126,11 @@ pub const timespec = extern struct {
pub const sigset_t = u32;
pub const empty_sigset: sigset_t = 0;
pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
pub const siginfo_t = extern struct {
signo: c_int,
errno: c_int,

View File

@ -672,8 +672,11 @@ test "sigaction" {
// Check that we can read it back correctly.
os.sigaction(os.SIGUSR1, null, &old_sa);
testing.expectEqual(S.handler, old_sa.handler.sigaction.?);
testing.expect((old_sa.flags & os.SA_RESETHAND) != 0);
testing.expect((old_sa.flags & os.SA_SIGINFO) != 0);
// Invoke the handler.
try os.raise(os.SIGUSR1);
testing.expect(signal_test_failed == false);
// Check if the handler has been correctly reset to SIG_DFL
os.sigaction(os.SIGUSR1, null, &old_sa);
testing.expectEqual(os.SIG_DFL, old_sa.handler.sigaction);
}