summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-04 02:32:59 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-04 02:32:59 +0000
commit620a0037a55e5f10f5467d07ee0b789095a37eb6 (patch)
treec92120c05819708fd5a984ccf6c0f1d0c80ab63a /base
parent872198eb761ef4632eed9abeef2c347380a6e415 (diff)
downloadchromium_src-620a0037a55e5f10f5467d07ee0b789095a37eb6.zip
chromium_src-620a0037a55e5f10f5467d07ee0b789095a37eb6.tar.gz
chromium_src-620a0037a55e5f10f5467d07ee0b789095a37eb6.tar.bz2
[Mac] Move the reset of signal handlers to be very soon after the fork, before we do any mach IPC.
The MachPortSender constructor can sometimes hang forever (gets stuck in bootstrap_look_up()), so it is important to reset the child's signal handlers as early as possible. Nico would like me to mention that this was his idea. This is take two. I couldn't reproduce the unit_tests failures either locally or on the release try bots. BUG=35374 TEST=If in the forever backwards spinner state, closing the tab should not quit the browser. TEST=In general, renderers and extensions and plugins should still work. Review URL: http://codereview.chromium.org/3302009 TBR=rohitrao@chromium.org Review URL: http://codereview.chromium.org/3322013 TBR=rohitrao@chromium.org Review URL: http://codereview.chromium.org/3360009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/process_util_posix.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index d50ff9f..8fe64d0 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -109,6 +109,15 @@ void StackDumpSignalHandler(int signal) {
_exit(1);
}
+void ResetChildSignalHandlersToDefaults() {
+ // The previous signal handlers are likely to be meaningless in the child's
+ // context so we reset them to the defaults for now. http://crbug.com/44953
+ // These signal handlers are setup in browser_main.cc:BrowserMain
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+}
+
} // anonymous namespace
ProcessId GetCurrentProcId() {
@@ -323,6 +332,9 @@ static pid_t fork_and_get_task(task_t* child_task) {
case -1:
return pid;
case 0: { // child
+ // Must reset signal handlers before doing any mach IPC, as the mach IPC
+ // calls can potentially hang forever.
+ ResetChildSignalHandlersToDefaults();
MachSendMessage child_message(/* id= */0);
if (!child_message.AddDescriptor(mach_task_self())) {
LOG(ERROR) << "child AddDescriptor(mach_task_self()) failed.";
@@ -529,12 +541,10 @@ bool LaunchApp(
RestoreDefaultExceptionHandler();
#endif
- // The previous signal handlers are likely to be meaningless in the child's
- // context so we reset them to the defaults for now. http://crbug.com/44953
- // These signal handlers are setup in browser_main.cc:BrowserMain
- signal(SIGTERM, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
- signal(SIGINT, SIG_DFL);
+ // On mac, the signal handlers are reset in |fork_and_get_task()|.
+#if !defined(OS_MACOSX)
+ ResetChildSignalHandlersToDefaults();
+#endif
#if 0
// When debugging it can be helpful to check that we really aren't making