Better handling of sigset_t on LP32.
The main motivation here is that the sigprocmask in pthread_exit wasn't
actually blocking the real-time signals, and debuggerd (amongst other
things) is using them. I wasn't able to write a test that actually won
that race but I did write an equivalent one for posix_spawn.
This also fixes all the uses of sigset_t where the sigset_t isn't
exposed to the outside (which we can't easily fix because it would be
an ABI change).
Bug: https://issuetracker.google.com/72291624
Test: ran tests
Change-Id: Ib6eebebc5a7b0150079f1cb79593247917dcf750
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp
index d2e4ea1..dfce0dc 100644
--- a/tests/spawn_test.cpp
+++ b/tests/spawn_test.cpp
@@ -376,6 +376,7 @@
sigset_t just_SIGALRM;
sigemptyset(&just_SIGALRM);
sigaddset(&just_SIGALRM, SIGALRM);
+
ASSERT_EQ(0, posix_spawnattr_setsigdefault(&sa, &just_SIGALRM));
ASSERT_EQ(0, posix_spawnattr_setflags(&sa, POSIX_SPAWN_SETSIGDEF));
@@ -393,15 +394,18 @@
// child without first defaulting any caught signals (http://b/68707996).
static pid_t parent = getpid();
+ setpgid(0, 0);
+
pid_t pid = fork();
ASSERT_NE(-1, pid);
if (pid == 0) {
+ signal(SIGRTMIN, SIG_IGN);
for (size_t i = 0; i < 1024; ++i) {
- kill(0, SIGWINCH);
+ kill(0, SIGRTMIN);
usleep(10);
}
- return;
+ _exit(99);
}
// We test both with and without attributes, because they used to be
@@ -417,11 +421,15 @@
posix_spawnattr_t* attrs[] = { nullptr, &attr1, &attr2 };
- ScopedSignalHandler ssh(SIGWINCH, [](int) { ASSERT_EQ(getpid(), parent); });
+ // We use a real-time signal because that's a tricky case for LP32
+ // because our sigset_t was too small.
+ ScopedSignalHandler ssh(SIGRTMIN, [](int) { ASSERT_EQ(getpid(), parent); });
ExecTestHelper eth;
eth.SetArgs({"true", nullptr});
for (size_t i = 0; i < 128; ++i) {
posix_spawn(nullptr, "true", nullptr, attrs[i % 3], eth.GetArgs(), nullptr);
}
+
+ AssertChildExited(pid, 99);
}