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

Unified Diff: chrome/browser/chrome_browser_main_posix.cc

Issue 12314106: [Mac] Do not forward graceful shutdown from child signal handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops, ref the bug. Created 7 years, 10 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: chrome/browser/chrome_browser_main_posix.cc
diff --git a/chrome/browser/chrome_browser_main_posix.cc b/chrome/browser/chrome_browser_main_posix.cc
index 1bb0f2c822d402de098e67c7164a37b818da5252..cb83f97beaf0d439cb2e18aa90019bca2bfe51a0 100644
--- a/chrome/browser/chrome_browser_main_posix.cc
+++ b/chrome/browser/chrome_browser_main_posix.cc
@@ -40,6 +40,13 @@ namespace {
void SIGCHLDHandler(int signal) {
}
+// The OSX fork() implementation can crash in the child process before
+// fork() returns. In that case, the shutdown pipe will still be
+// shared with the parent process. To prevent child crashes from
+// causing parent shutdowns, |g_pipe_pid| is the pid for the process
+// which registered |g_shutdown_pipe_write_fd|.
+// See <http://crbug.com/175341>.
+pid_t g_pipe_pid = -1;
int g_shutdown_pipe_write_fd = -1;
int g_shutdown_pipe_read_fd = -1;
@@ -51,6 +58,7 @@ void GracefulShutdownHandler(int signal) {
action.sa_handler = SIG_DFL;
RAW_CHECK(sigaction(signal, &action, NULL) == 0);
+ RAW_CHECK(g_pipe_pid == getpid());
RAW_CHECK(g_shutdown_pipe_write_fd != -1);
RAW_CHECK(g_shutdown_pipe_read_fd != -1);
size_t bytes_written = 0;
@@ -299,6 +307,7 @@ void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() {
if (ret < 0) {
PLOG(DFATAL) << "Failed to create pipe";
} else {
+ g_pipe_pid = getpid();
g_shutdown_pipe_read_fd = pipefd[0];
g_shutdown_pipe_write_fd = pipefd[1];
#if !defined(ADDRESS_SANITIZER) && !defined(KEEP_SHADOW_STACKS)
« 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