summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 19:09:00 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 19:09:00 +0000
commit20595ea7d410241f8e44dde5768a9355dfc82a2d (patch)
tree780b09db9b4db1435ea7f63121f598c937ee6883
parentf0d78c06446769d190f3c8b1e7714de63553b3e5 (diff)
downloadchromium_src-20595ea7d410241f8e44dde5768a9355dfc82a2d.zip
chromium_src-20595ea7d410241f8e44dde5768a9355dfc82a2d.tar.gz
chromium_src-20595ea7d410241f8e44dde5768a9355dfc82a2d.tar.bz2
posix: make ctl-C work within gdb for dropping to a console.
See comment in commit for gory details. Review URL: http://codereview.chromium.org/53113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13374 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug_util.h2
-rw-r--r--chrome/app/chrome_dll_main.cc16
2 files changed, 17 insertions, 1 deletions
diff --git a/base/debug_util.h b/base/debug_util.h
index 8ae0a2b..de49c43 100644
--- a/base/debug_util.h
+++ b/base/debug_util.h
@@ -44,7 +44,7 @@ class DebugUtil {
// Are we running under a debugger?
// On OS X, the underlying mechanism doesn't work when the sandbox is enabled.
- // To get around this, this function caches it's value.
+ // To get around this, this function caches its value.
// WARNING: Because of this, on OS X, a call MUST be made to this function
// BEFORE the sandbox is enabled.
static bool BeingDebugged();
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 8cc1e93..5281553 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -15,6 +15,8 @@
#include <atlapp.h>
#include <malloc.h>
#include <new.h>
+#elif defined(OS_POSIX)
+#include <signal.h>
#endif
#if defined(OS_LINUX)
@@ -315,6 +317,20 @@ int ChromeMain(int argc, const char** argv) {
browser_pid = StringToInt(WideToASCII(channel_name));
DCHECK(browser_pid != 0);
+
+#if defined(OS_POSIX)
+ // When you hit Ctrl-C in a terminal running the browser
+ // process, a SIGINT is delivered to the entire process group.
+ // When debugging the browser process via gdb, gdb catches the
+ // SIGINT for the browser process (and dumps you back to the gdb
+ // console) but doesn't for the child processes, killing them.
+ // The fix is to have child processes ignore SIGINT; they'll die
+ // on their own when the browser process goes away.
+ // Note that we *can't* rely on DebugUtil::BeingDebugged to catch this
+ // case because we are the child process, which is not being debugged.
+ if (!DebugUtil::BeingDebugged())
+ signal(SIGINT, SIG_IGN);
+#endif
}
SetupCRT(parsed_command_line);