diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-05 00:42:33 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-05 00:42:33 +0000 |
commit | 103c215374c596425c599483053f69805720da71 (patch) | |
tree | 7f474bb6fe4a61b2dc967c33012700e1a4b24926 /chrome/app | |
parent | 619b1ca85240c4658cb66e527b7dd75cd7dd61a9 (diff) | |
download | chromium_src-103c215374c596425c599483053f69805720da71.zip chromium_src-103c215374c596425c599483053f69805720da71.tar.gz chromium_src-103c215374c596425c599483053f69805720da71.tar.bz2 |
POSIX: sanitise signal handling state at startup.
BUG=29279
http://codereview.chromium.org/467028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r-- | chrome/app/chrome_dll_main.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index e83e07d..5d58d6e 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[] = + {SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, + SIGALRM, SIGTERM, SIGCHLD, SIGBUS, SIGTRAP}; // 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. |