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

Unified Diff: content/zygote/zygote_linux.cc

Issue 19231006: chrome: respect --child-clean-exit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made comments better. Created 7 years, 5 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 | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/zygote/zygote_linux.cc
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc
index 893002281218e863a33bfeca97cab5f949d23efe..9dfd56c746c237617f01ff91e2bc24eed4d0c9d7 100644
--- a/content/zygote/zygote_linux.cc
+++ b/content/zygote/zygote_linux.cc
@@ -5,6 +5,7 @@
#include "content/zygote/zygote_linux.h"
#include <fcntl.h>
+#include <pthread.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -24,6 +25,7 @@
#include "content/common/set_process_title.h"
#include "content/common/zygote_commands_linux.h"
#include "content/public/common/content_descriptors.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/sandbox_linux.h"
#include "content/public/common/zygote_fork_delegate_linux.h"
@@ -110,7 +112,18 @@ bool Zygote::HandleRequestFromBrowser(int fd) {
if (len == 0 || (len == -1 && errno == ECONNRESET)) {
// EOF from the browser. We should die.
- _exit(0);
+ if (CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kChildCleanExit)) {
+ // Zygote children are reaped in a separate detached thread (see the
+ // implementation of EnsureProcessGetsReaped()). If we _exit() or exit()
+ // here, the reaping wait may not have completed. For this reason, we
+ // only terminate this thread (instead of terminating the whole process).
+ // The zygote will then exit only when all children have exited and have
+ // been reaped.
+ pthread_exit(0);
+ }
+ else
+ _exit(0);
return false;
}
@@ -196,7 +209,9 @@ void Zygote::HandleGetTerminationStatus(int fd,
if (UsingSUIDSandbox())
child = real_pids_to_sandbox_pids[child];
if (child) {
- if (known_dead) {
+ if (known_dead &&
+ !CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kChildCleanExit)) {
// If we know that the process is already dead and the kernel is cleaning
// it up, we do want to wait until it becomes a zombie and not risk
// returning eroneously that it is still running. However, we do not
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698