Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Mac] Do not forward graceful shutdown from child signal handlers.

OSX implements fork() as a userland wrapper around a system call.  If
a graceful-shutdown signal is received before the graceful-shutdown
pipe has been replaced, the parent process will shutdown.  Change to
force a crash in the child in this case.

BUG=175341

Review URL: https://codereview.chromium.org/12314106

git-svn-id: http://src.chromium.org/svn/trunk/src/chrome/browser@184805 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information...
commit f350658205bbd91b45f16259abdeeb8ea940966c 1 parent a20c899
shess@chromium.org authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 chrome_browser_main_posix.cc
View
9 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)
Please sign in to comment.
Something went wrong with that request. Please try again.