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

Side by Side Diff: sandbox/linux/suid/init_process.c

Issue 9661001: If using the suid sandbox, but not using the seccomp sandbox, there is a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #define _GNU_SOURCE 5 #define _GNU_SOURCE
6 #include "init_process.h" 6 #include "init_process.h"
7 7
8 #include <dirent.h> 8 #include <dirent.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 sigemptyset(&mask); 133 sigemptyset(&mask);
134 sigaddset(&mask, SIGCHLD); 134 sigaddset(&mask, SIGCHLD);
135 sigprocmask(SIG_BLOCK, &mask, NULL); 135 sigprocmask(SIG_BLOCK, &mask, NULL);
136 136
137 // Notify other processes that we are done initializing 137 // Notify other processes that we are done initializing
138 if (write(init_fd, " ", 1)) { } 138 if (write(init_fd, " ", 1)) { }
139 close(init_fd); 139 close(init_fd);
140 140
141 // Handle dying processes that have been re-parented to the "init" process 141 // Handle dying processes that have been re-parented to the "init" process
142 for (;;) { 142 for (;;) {
143 // Wait until we receive a SIGCHLD signal. Our signal handler doesn't
144 // actually need to do anything, though
145 sigwaitinfo(&mask, NULL);
146
147 bool retry = false; 143 bool retry = false;
148 do { 144 do {
149 for (;;) { 145 for (;;) {
150 // Reap all exit codes of our child processes. This includes both 146 // Reap all exit codes of our child processes. This includes both
151 // processes that originally were our immediate children, and processes 147 // processes that originally were our immediate children, and processes
152 // that have since been re-parented to be our children. 148 // that have since been re-parented to be our children.
153 int status; 149 int status;
154 pid_t pid = waitpid(0, &status, __WALL | WNOHANG); 150 pid_t pid = waitpid(0, &status, __WALL | WNOHANG);
155 if (pid <= 0) { 151 if (pid <= 0) {
156 break; 152 break;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // particularly true, because scanning "/proc" cannot possibly be 186 // particularly true, because scanning "/proc" cannot possibly be
191 // an atomic operation. 187 // an atomic operation.
192 // If we find that we no longer appear to have any children, we check 188 // If we find that we no longer appear to have any children, we check
193 // one more time whether there are any children we can now reap. 189 // one more time whether there are any children we can now reap.
194 // They might have died while we were scanning "/proc" and if so, 190 // They might have died while we were scanning "/proc" and if so,
195 // they should now show up. 191 // they should now show up.
196 retry = true; 192 retry = true;
197 } 193 }
198 } 194 }
199 } while (retry); 195 } while (retry);
196
197 // Wait until we receive a SIGCHLD signal. Our signal handler doesn't
198 // actually need to do anything, though
199 sigwaitinfo(&mask, NULL);
200 } 200 }
201 } 201 }
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