diff options
author | Ryan Prichard <rprichard@google.com> | 2018-04-09 16:26:20 -0700 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2018-04-10 14:42:46 -0700 |
commit | 5a0fe3e8bff96c465d00823f07ce36caac1b104d (patch) | |
tree | 4f653277129ed48adc344795b5423008c03a76ef | |
parent | 45cd095f9d3b2332611eb3bc19907ad4f33950e4 (diff) | |
download | bionic-5a0fe3e8bff96c465d00823f07ce36caac1b104d.tar.gz |
spawn.signal_stress: reap spawned children on exit
Test: adb shell \
/data/nativetest64/bionic-unit-tests-static/bionic-unit-tests-static \
--gtest_filter=spawn.signal_stress
Bug: b/77824306
Change-Id: I970d1a4d0f8ac9621e676f32f838fc2f638d9750
(cherry picked from commit 344969c849cce92e58ff483a035210c52da7910b)
-rw-r--r-- | tests/spawn_test.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp index 3cb2a0d04..1b6a5d487 100644 --- a/tests/spawn_test.cpp +++ b/tests/spawn_test.cpp @@ -463,10 +463,19 @@ TEST(spawn, signal_stress) { // because our sigset_t was too small. ScopedSignalHandler ssh(SIGRTMIN, [](int) { ASSERT_EQ(getpid(), parent); }); + const size_t pid_count = 128; + pid_t spawned_pids[pid_count]; + 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); + for (size_t i = 0; i < pid_count; ++i) { + pid_t spawned_pid; + ASSERT_EQ(0, posix_spawn(&spawned_pid, "true", nullptr, attrs[i % 3], eth.GetArgs(), nullptr)); + spawned_pids[i] = spawned_pid; + } + + for (pid_t spawned_pid : spawned_pids) { + ASSERT_EQ(spawned_pid, TEMP_FAILURE_RETRY(waitpid(spawned_pid, nullptr, 0))); } AssertChildExited(pid, 99); |