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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <assert.h> 5 #include <assert.h>
6 #include <dirent.h> 6 #include <dirent.h>
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <pty.h> 9 #include <pty.h>
10 #include <sys/prctl.h> 10 #include <sys/prctl.h>
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 write(fds[0], &ch, 1); 700 write(fds[0], &ch, 1);
701 read(fds[0], &ch, 1); 701 read(fds[0], &ch, 1);
702 _exit(1); 702 _exit(1);
703 } 703 }
704 rc = ptrace(PTRACE_ATTACH, pid, 0, 0); 704 rc = ptrace(PTRACE_ATTACH, pid, 0, 0);
705 assert(rc == -1 && errno == EPERM); 705 assert(rc == -1 && errno == EPERM);
706 write(fds[1], &ch, 1); 706 write(fds[1], &ch, 1);
707 read(fds[1], &ch, 1); 707 read(fds[1], &ch, 1);
708 rc = ptrace(PTRACE_ATTACH, pid, 0, 0); 708 rc = ptrace(PTRACE_ATTACH, pid, 0, 0);
709 assert(rc == 0); 709 assert(rc == 0);
710
711 // Now clean up. We have to collect the subprocess's stopped state
712 // with waitpid() otherwise PTRACE_KILL will not successfully kill
713 // the subprocess.
714 int status;
715 rc = waitpid(pid, &status, 0);
716 assert(rc == pid);
717 assert(WIFSTOPPED(status));
718 assert(WSTOPSIG(status) == SIGSTOP);
719
710 rc = ptrace(PTRACE_KILL, pid, 0, 0); 720 rc = ptrace(PTRACE_KILL, pid, 0, 0);
711 assert(rc == 0); 721 assert(rc == 0);
722
723 rc = waitpid(pid, &status, 0);
724 assert(rc == pid);
725 assert(WIFSIGNALED(status));
726 assert(WTERMSIG(status) == SIGKILL);
712 } 727 }
713 728
714 struct testcase { 729 struct testcase {
715 const char *test_name; 730 const char *test_name;
716 void (*test_func)(); 731 void (*test_func)();
717 }; 732 };
718 733
719 struct testcase all_tests[] = { 734 struct testcase all_tests[] = {
720 #include "test-list.h" 735 #include "test-list.h"
721 { NULL, NULL }, 736 { NULL, NULL },
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 if (failures == 0) { 821 if (failures == 0) {
807 printf("OK\n"); 822 printf("OK\n");
808 return 0; 823 return 0;
809 } 824 }
810 else { 825 else {
811 printf("%i FAILURE(S)\n", failures); 826 printf("%i FAILURE(S)\n", failures);
812 return 1; 827 return 1;
813 } 828 }
814 } 829 }
815 } 830 }
OLDNEW
« 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