mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 14:09:12 +00:00
Introduce sigtimedwait() and sigwaitinfo()
This change also invents sigcountset() and strsignal_r() and improves the quality of siginfo_t handling.
This commit is contained in:
parent
7ae556463a
commit
467a332e38
41 changed files with 887 additions and 345 deletions
|
@ -49,10 +49,6 @@ static uint64_t Rando(void) {
|
|||
return x;
|
||||
}
|
||||
|
||||
void SetUp(void) {
|
||||
__print_maps();
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *want;
|
||||
const char *fmt;
|
||||
|
@ -356,6 +352,30 @@ TEST(ksnprintf, badUtf16) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST(ksnprintf, negativeOverflowIdiom_isSafe) {
|
||||
int i, n;
|
||||
char golden[11];
|
||||
struct {
|
||||
char underflow[11];
|
||||
char buf[11];
|
||||
char overflow[11];
|
||||
} u;
|
||||
memset(golden, -1, 11);
|
||||
memset(u.underflow, -1, 11);
|
||||
memset(u.overflow, -1, 11);
|
||||
i = 0;
|
||||
n = 11;
|
||||
i += ksnprintf(u.buf + i, n - i, "hello");
|
||||
ASSERT_STREQ("hello", u.buf);
|
||||
i += ksnprintf(u.buf + i, n - i, " world");
|
||||
ASSERT_STREQ("hello w...", u.buf);
|
||||
i += ksnprintf(u.buf + i, n - i, " i love you");
|
||||
ASSERT_STREQ("hello w...", u.buf);
|
||||
ASSERT_EQ(i, 5 + 6 + 11);
|
||||
ASSERT_EQ(0, memcmp(golden, u.underflow, 11));
|
||||
ASSERT_EQ(0, memcmp(golden, u.overflow, 11));
|
||||
}
|
||||
|
||||
TEST(ksnprintf, truncation) {
|
||||
char buf[16] = {0};
|
||||
rngset(buf, sizeof(buf) - 1, lemur64, -1);
|
||||
|
|
|
@ -27,8 +27,13 @@ TEST(strsignal, test) {
|
|||
EXPECT_STREQ("SIGALRM", strsignal(SIGALRM));
|
||||
EXPECT_STREQ("SIGUSR1", strsignal(SIGUSR1));
|
||||
EXPECT_STREQ("SIGSTOP", strsignal(SIGSTOP));
|
||||
EXPECT_STREQ("SIG099", strsignal(99));
|
||||
EXPECT_STREQ("SIG100", strsignal(100));
|
||||
EXPECT_STREQ("SIGWUT", strsignal(-1));
|
||||
EXPECT_STREQ("SIGWUT", strsignal(9001));
|
||||
EXPECT_STREQ("666", strsignal(666));
|
||||
EXPECT_STREQ("-1", strsignal(-1));
|
||||
EXPECT_STREQ("9001", strsignal(9001));
|
||||
}
|
||||
|
||||
TEST(strsignal, realtime) {
|
||||
if (!SIGRTMIN) return;
|
||||
ASSERT_STREQ("SIGRTMIN", strsignal(SIGRTMIN));
|
||||
ASSERT_STREQ("SIGRTMIN+1", strsignal(SIGRTMIN + 1));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue