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

Unified Diff: src/platform/minijail/env.cc

Issue 1570004: waitpid() on the child process when changing namespaces (Closed)
Patch Set: use waitpid status properly Created 10 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 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: src/platform/minijail/env.cc
diff --git a/src/platform/minijail/env.cc b/src/platform/minijail/env.cc
index 5ee0667515663f988bf5e51f8f54ce419e57e200..bd6eb03ff674824340e14070826b4641def8a3db 100644
--- a/src/platform/minijail/env.cc
+++ b/src/platform/minijail/env.cc
@@ -27,6 +27,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <unistd.h>
#include <base/logging.h>
@@ -203,9 +204,20 @@ bool Env::EnterNamespace(int namespaces) const {
return false;
}
if (pid) {
+ // We want to wait on the child pid to ensure that pid-tracking code
+ // isn't completely broken.
+ int status = 0;
+ waitpid(pid, &status, 0);
// Kill the original process without atexit handlers.
- DLOG(INFO) << "original process death:" << pid;
- _exit(0);
+ DLOG(INFO) << "jailed process death:" << pid;
+ if (WIFEXITED(status)) {
+ _exit(WEXITSTATUS(status));
+ }
+ if (WIFSIGNALED(status)) {
+ _exit(WTERMSIG(status));
+ }
+ DLOG(INFO) << "unknown terminal condition for child";
+ _exit(1);
}
DLOG(INFO) << "Success: " << getpid();
return true;
« 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