From 20595ea7d410241f8e44dde5768a9355dfc82a2d Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Wed, 8 Apr 2009 19:09:00 +0000 Subject: 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 --- base/debug_util.h | 2 +- chrome/app/chrome_dll_main.cc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 #include #include +#elif defined(OS_POSIX) +#include #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); -- cgit v1.1