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

Unified Diff: content/browser/child_process_launcher.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/app/content_main_runner.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index e497762aff8ebbd651e8467c6c0409ff7c8f8fe2..9bc7b374dfde9df24a9c9e5c2602483f13c41402 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -339,19 +339,23 @@ class ChildProcessLauncher::Context
if (!process_.handle())
return;
- if (!terminate_child_on_shutdown_)
- return;
-
- // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So
- // don't this on the UI/IO threads.
- BrowserThread::PostTask(
- BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
- base::Bind(
- &Context::TerminateInternal,
+ if (CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kWaitForChildrenBeforeExiting))
+ // When --wait-for-children-before-exiting is provided on the command
+ // line, we want the UI thread to wait for the zygote to exit before
+ // proceeding with the rest of the shut down.
+ TerminateAndWaitForExit(zygote_, process_.handle());
+ else
+ // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So
+ // don't this on the UI/IO threads.
+ BrowserThread::PostTask(
+ BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
+ base::Bind(
+ &Context::TerminateInternal,
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
- zygote_,
+ zygote_,
#endif
- process_.handle()));
+ process_.handle()));
process_.set_handle(base::kNullProcessHandle);
}
@@ -361,6 +365,20 @@ class ChildProcessLauncher::Context
process.SetProcessBackgrounded(background);
}
+ static void TerminateAndWaitForExit(
+ bool zygote,
+ base::ProcessHandle handle) {
+ base::Process process(handle);
+ if (zygote) {
+ while(ZygoteHostImpl::GetInstance()->GetTerminationStatus(
+ handle,
+ false,
+ NULL) == base::TERMINATION_STATUS_STILL_RUNNING)
+ sleep(2);
+ }
+ process.Close();
+ }
+
static void TerminateInternal(
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
bool zygote,
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698