Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: tests/test_syscalls.cc

Issue 3363006: [seccomp-sandbox] Fix test_prctl so that it does not leave behind a zombie process (Closed)
Patch Set: Go back to PTRACE_KILL, but with extra waitpid() call Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_syscalls.cc
diff --git a/tests/test_syscalls.cc b/tests/test_syscalls.cc
index c1b7360361131eafc3f850048aec375058875834..c6d86c93444918b2f2a6169f9de6776a62f8fbcf 100644
--- a/tests/test_syscalls.cc
+++ b/tests/test_syscalls.cc
@@ -707,8 +707,23 @@ TEST(test_prctl) {
read(fds[1], &ch, 1);
rc = ptrace(PTRACE_ATTACH, pid, 0, 0);
assert(rc == 0);
+
+ // Now clean up. We have to collect the subprocess's stopped state
+ // with waitpid() otherwise PTRACE_KILL will not successfully kill
+ // the subprocess.
+ int status;
+ rc = waitpid(pid, &status, 0);
+ assert(rc == pid);
+ assert(WIFSTOPPED(status));
+ assert(WSTOPSIG(status) == SIGSTOP);
+
rc = ptrace(PTRACE_KILL, pid, 0, 0);
assert(rc == 0);
+
+ rc = waitpid(pid, &status, 0);
+ assert(rc == pid);
+ assert(WIFSIGNALED(status));
+ assert(WTERMSIG(status) == SIGKILL);
}
struct testcase {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698