summaryrefslogtreecommitdiff
path: root/tests/spawn_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-01-24 18:54:38 -0800
committerElliott Hughes <enh@google.com>2018-01-26 13:04:57 -0800
commit4b1c6e73850d2e77c6d05a2f7dad8e3e8c928103 (patch)
tree685c224a8f997ec868c9c0a93e194fe2ae2d8eb8 /tests/spawn_test.cpp
parent73871ad09be8a8259171d606c4e3e3cf08d4733c (diff)
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
Diffstat (limited to 'tests/spawn_test.cpp')
-rw-r--r--tests/spawn_test.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp
index d2e4ea1da..dfce0dc58 100644
--- a/tests/spawn_test.cpp
+++ b/tests/spawn_test.cpp
@@ -376,6 +376,7 @@ TEST(spawn, posix_spawn_POSIX_SPAWN_SETSIGDEF) {
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 @@ TEST(spawn, signal_stress) {
// 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 @@ TEST(spawn, signal_stress) {
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);
}