sem_timedwait with a null timeout doesn't mean "forever".
It actually means "crash immediately". Well, it's an error. And callers are much more likely to realize their mistake if we crash immediately rather than return EINVAL. Historically, glibc has crashed and bionic -- before the recent changes -- returned EINVAL, so this is a behavior change. Change-Id: I0c2373a6703b20b8a97aacc1e66368a5885e8c51
This commit is contained in:
@@ -131,6 +131,13 @@ TEST(semaphore, sem_timedwait) {
|
||||
ASSERT_EQ(0, sem_destroy(&s));
|
||||
}
|
||||
|
||||
TEST(semaphore_DeathTest, sem_timedwait_null_timeout) {
|
||||
sem_t s;
|
||||
ASSERT_EQ(0, sem_init(&s, 0, 0));
|
||||
|
||||
ASSERT_EXIT(sem_timedwait(&s, nullptr), testing::KilledBySignal(SIGSEGV), "");
|
||||
}
|
||||
|
||||
TEST(semaphore, sem_getvalue) {
|
||||
sem_t s;
|
||||
ASSERT_EQ(0, sem_init(&s, 0, 0));
|
||||
|
||||
Reference in New Issue
Block a user