Index: content/app/content_main_runner.cc |
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc |
index 5bbdb9b35d81c001374fa3b495ae5430bc16224a..1e80ac034d8eefa3252321daf4be9ae318f0f8f8 100644 |
--- a/content/app/content_main_runner.cc |
+++ b/content/app/content_main_runner.cc |
@@ -5,6 +5,12 @@ |
#include "content/public/app/content_main_runner.h" |
#include <stdlib.h> |
+#include <sys/types.h> |
+#include <sys/wait.h> |
+#if defined(OS_POSIX) |
+#include <errno.h> |
+#endif // OS_POSIX |
+ |
#include "base/allocator/allocator_extension.h" |
#include "base/at_exit.h" |
@@ -786,6 +792,18 @@ class ContentMainRunnerImpl : public ContentMainRunner { |
exit_manager_.reset(NULL); |
+#if defined(OS_POSIX) |
+ // Wait for children to exit if --wait-for-children-before-exiting is |
+ // passed. |
+ if (CommandLine::ForCurrentProcess()-> |
+ HasSwitch(switches::kWaitForChildrenBeforeExiting)) { |
+ for (;;) { |
+ if (wait(NULL) < 0 && errno == ECHILD) |
+ break; |
+ } |
+ } |
+#endif // OS_POSIX |
+ |
delegate_ = NULL; |
is_shutdown_ = true; |
} |