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

Unified Diff: chrome/browser/browser_main_posix.cc

Issue 7464013: Register signal handlers after shutdown pipe is setup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 3 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 | chrome/browser/chromeos/login/base_login_display_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_main_posix.cc
diff --git a/chrome/browser/browser_main_posix.cc b/chrome/browser/browser_main_posix.cc
index 518daaa22fb6070549334179e8ba7e59dfbc863b..5855abc451770ff3e8ea2b083b13116f08470a60 100644
--- a/chrome/browser/browser_main_posix.cc
+++ b/chrome/browser/browser_main_posix.cc
@@ -55,19 +55,19 @@ void GracefulShutdownHandler(int signal) {
} while (bytes_written < sizeof(signal));
}
-// See comment in |PreEarlyInitialization()|, where sigaction is called.
+// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
void SIGHUPHandler(int signal) {
RAW_CHECK(signal == SIGHUP);
GracefulShutdownHandler(signal);
}
-// See comment in |PreEarlyInitialization()|, where sigaction is called.
+// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
void SIGINTHandler(int signal) {
RAW_CHECK(signal == SIGINT);
GracefulShutdownHandler(signal);
}
-// See comment in |PreEarlyInitialization()|, where sigaction is called.
+// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
void SIGTERMHandler(int signal) {
RAW_CHECK(signal == SIGTERM);
GracefulShutdownHandler(signal);
@@ -199,24 +199,6 @@ void BrowserMainPartsPosix::PreEarlyInitialization() {
action.sa_handler = SIGCHLDHandler;
CHECK(sigaction(SIGCHLD, &action, NULL) == 0);
- // If adding to this list of signal handlers, note the new signal probably
- // needs to be reset in child processes. See
- // base/process_util_posix.cc:LaunchProcess.
-
- // We need to handle SIGTERM, because that is how many POSIX-based distros ask
- // processes to quit gracefully at shutdown time.
- memset(&action, 0, sizeof(action));
- action.sa_handler = SIGTERMHandler;
- CHECK(sigaction(SIGTERM, &action, NULL) == 0);
- // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If
- // the browser process is being debugged, GDB will catch the SIGINT first.
- action.sa_handler = SIGINTHandler;
- CHECK(sigaction(SIGINT, &action, NULL) == 0);
- // And SIGHUP, for when the terminal disappears. On shutdown, many Linux
- // distros send SIGHUP, SIGTERM, and then SIGKILL.
- action.sa_handler = SIGHUPHandler;
- CHECK(sigaction(SIGHUP, &action, NULL) == 0);
-
const std::string fd_limit_string =
parsed_command_line().GetSwitchValueASCII(
switches::kFileDescriptorLimit);
@@ -262,6 +244,27 @@ void BrowserMainPartsPosix::PostMainMessageLoopStart() {
LOG(DFATAL) << "Failed to create shutdown detector task.";
}
}
+ // Setup signal handlers for shutdown AFTER shutdown pipe is setup because
+ // it may be called right away after handler is set.
+
+ // If adding to this list of signal handlers, note the new signal probably
+ // needs to be reset in child processes. See
+ // base/process_util_posix.cc:LaunchProcess.
+
+ // We need to handle SIGTERM, because that is how many POSIX-based distros ask
+ // processes to quit gracefully at shutdown time.
+ struct sigaction action;
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = SIGTERMHandler;
+ CHECK(sigaction(SIGTERM, &action, NULL) == 0);
+ // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If
+ // the browser process is being debugged, GDB will catch the SIGINT first.
+ action.sa_handler = SIGINTHandler;
+ CHECK(sigaction(SIGINT, &action, NULL) == 0);
+ // And SIGHUP, for when the terminal disappears. On shutdown, many Linux
+ // distros send SIGHUP, SIGTERM, and then SIGKILL.
+ action.sa_handler = SIGHUPHandler;
+ CHECK(sigaction(SIGHUP, &action, NULL) == 0);
#if defined(TOOLKIT_USES_GTK) && !defined(OS_CHROMEOS)
printing::PrintingContextCairo::SetCreatePrintDialogFunction(
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/base_login_display_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698