mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
Fix inability to add some signals to mask on NT (#596)
This commit is contained in:
parent
d861d2787b
commit
598640864a
2 changed files with 20 additions and 1 deletions
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
struct Signals __sig; // TODO(jart): Need TLS
|
struct Signals __sig; // TODO(jart): Need TLS
|
||||||
|
|
||||||
|
#define GetSigBit(XXSIG) (1ull << (((XXSIG)-1) & 63))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes signal mask for main thread.
|
* Changes signal mask for main thread.
|
||||||
* @return 0 on success, or -1 w/ errno
|
* @return 0 on success, or -1 w/ errno
|
||||||
|
@ -51,7 +53,7 @@ textwindows int __sig_mask(int how, const sigset_t *neu, sigset_t *old) {
|
||||||
__sig.mask.__bits[i] = neu->__bits[i];
|
__sig.mask.__bits[i] = neu->__bits[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__sig.mask.__bits[0] &= ~(SIGKILL | SIGSTOP);
|
__sig.mask.__bits[0] &= ~(GetSigBit(SIGKILL) | GetSigBit(SIGSTOP));
|
||||||
}
|
}
|
||||||
__sig_unlock();
|
__sig_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -59,3 +61,5 @@ textwindows int __sig_mask(int how, const sigset_t *neu, sigset_t *old) {
|
||||||
return einval();
|
return einval();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef GetSigBit
|
||||||
|
|
|
@ -78,3 +78,18 @@ TEST(sigprocmask, testMultipleBlockedDeliveriesOfSameSignal) {
|
||||||
EXPECT_EQ(1, n);
|
EXPECT_EQ(1, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(sigprocmask, testBlockingSIGINT) {
|
||||||
|
sigset_t neu, old;
|
||||||
|
struct sigaction oldsigint;
|
||||||
|
struct sigaction sa = {.sa_sigaction = OnSig, .sa_flags = SA_SIGINFO};
|
||||||
|
n = 0;
|
||||||
|
sigemptyset(&neu);
|
||||||
|
sigaddset(&neu, SIGINT);
|
||||||
|
EXPECT_EQ(0, sigprocmask(SIG_BLOCK, &neu, &old));
|
||||||
|
ASSERT_EQ(0, sigaction(SIGINT, &sa, &oldsigint));
|
||||||
|
ASSERT_EQ(0, raise(SIGINT));
|
||||||
|
EXPECT_EQ(0, n);
|
||||||
|
EXPECT_EQ(0, sigprocmask(SIG_SETMASK, &old, NULL));
|
||||||
|
EXPECT_EQ(0, sigaction(SIGINT, &oldsigint, 0));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue