Clean up the sigprocmask/pthread_sigmask implementation.

Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

Also, let's test the return side of these calls, not just the
setting.

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
This commit is contained in:
Elliott Hughes
2013-10-15 11:23:57 -07:00
parent abeafbd6d5
commit 19e62325c2
12 changed files with 46 additions and 97 deletions

View File

@@ -173,12 +173,28 @@ static void* SignalHandlerFn(void* arg) {
}
TEST(pthread, pthread_sigmask) {
// Check that SIGUSR1 isn't blocked.
sigset_t original_set;
sigemptyset(&original_set);
ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &original_set));
ASSERT_FALSE(sigismember(&original_set, SIGUSR1));
// Block SIGUSR1.
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL));
// Check that SIGUSR1 is blocked.
sigset_t final_set;
sigemptyset(&final_set);
ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &final_set));
ASSERT_TRUE(sigismember(&final_set, SIGUSR1));
// ...and that sigprocmask agrees with pthread_sigmask.
sigemptyset(&final_set);
ASSERT_EQ(0, sigprocmask(SIG_BLOCK, NULL, &final_set));
ASSERT_TRUE(sigismember(&final_set, SIGUSR1));
// Spawn a thread that calls sigwait and tells us what it received.
pthread_t signal_thread;
int received_signal = -1;
@@ -192,6 +208,9 @@ TEST(pthread, pthread_sigmask) {
ASSERT_EQ(0, pthread_join(signal_thread, &join_result));
ASSERT_EQ(SIGUSR1, received_signal);
ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(join_result));
// Restore the original signal mask.
ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
}
#if __BIONIC__