Chromium Code Reviews| 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..eff4911faf9751a92b2f627291201f747faec7f3 100644 |
| --- a/chrome/browser/chrome_browser_main_posix.cc |
| +++ b/chrome/browser/chrome_browser_main_posix.cc |
| @@ -40,6 +40,12 @@ 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|. |
|
viettrungluu
2013/02/25 23:15:06
Could you include a reference to the bug(s)?
Scott Hess - ex-Googler
2013/02/25 23:20:46
Done.
|
| +pid_t g_pipe_pid = -1; |
| int g_shutdown_pipe_write_fd = -1; |
| int g_shutdown_pipe_read_fd = -1; |
| @@ -51,6 +57,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; |
| @@ -301,6 +308,7 @@ void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() { |
| } else { |
| g_shutdown_pipe_read_fd = pipefd[0]; |
| g_shutdown_pipe_write_fd = pipefd[1]; |
| + g_pipe_pid = getpid(); |
|
viettrungluu
2013/02/25 23:15:06
Nit: You may as well initialize these in the same
Scott Hess - ex-Googler
2013/02/25 23:20:46
Done.
I was not willing to initialize the write f
|
| #if !defined(ADDRESS_SANITIZER) && !defined(KEEP_SHADOW_STACKS) |
| const size_t kShutdownDetectorThreadStackSize = PTHREAD_STACK_MIN; |
| #else |