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

Unified Diff: chrome/app/chrome_dll_main.cc

Issue 467028: POSIX: sanitise signal handling state at startup. (Closed)
Patch Set: Created 11 years 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/app/chrome_dll_main.cc
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index e83e07da032579a21ca0bdb87d02d8574aaf55a6..928d50fbbf6f4b5c0aa46820b9c469949b903379 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -340,6 +340,22 @@ int ChromeMain(int argc, char** argv) {
// Set C library locale to make sure CommandLine can parse argument values
// in correct encoding.
setlocale(LC_ALL, "");
+
+ // Sanitise our signal handling state. Signals that were ignored by our
+ // parent will also be ignored by us. We also inherit our parent's sigmask.
+ sigset_t empty_signal_set;
+ CHECK(0 == sigemptyset(&empty_signal_set));
+ CHECK(0 == sigprocmask(SIG_SETMASK, &empty_signal_set, NULL));
+
+ struct sigaction sigact;
+ memset(&sigact, 0, sizeof(sigact));
+ sigact.sa_handler = SIG_DFL;
+ static const int signals_to_reset[] =
Markus (顧孟勤) 2009/12/05 00:17:40 Please add the missing signals, that I mentioned t
+ {SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV,
+ SIGALRM, SIGTERM, SIGCHLD}; // SIGPIPE is set below.
+ for (unsigned i = 0; i < arraysize(signals_to_reset); i++) {
+ CHECK(0 == sigaction(signals_to_reset[i], &sigact, NULL));
+ }
#endif
// Initialize the command line.
« 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