Bug 20035 - gdb doesn't handle SIGINT on OS X when attaching to a process
Summary: gdb doesn't handle SIGINT on OS X when attaching to a process
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.11
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2016-05-02 20:30 UTC by edmunoz
Modified: 2016-06-05 20:55 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description edmunoz 2016-05-02 20:30:09 UTC
On OS X, when attaching to a simple program (e.g., infinite loop), gdb doesn't handle SIGINT signals sent to the debuggee, and hence the process can't be interrupted. This does not repro when the debuggee is started by gdb (using 'run').

1. Attach gdb
$ gdb a.out
(gdb) attach <PID>
(gdb) continue

2. Send a SIGINT to the debuggee
$ kill -2 <PID>

3. The debuggee exits
[Inferior 1 (process <PID>) exited normally]

gdb should handle the SIGINT sent to the debuggee, as shown when executing "info handle".

I tried this with executables built with clang and gcc (gcc-5 (Homebrew gcc 5.3.0) 5.3.0).

The configuration of gdb is

--host=x86_64-apple-darwin14.5.0 --target=x86_64-apple-darwin14.5.0
--with-gdb-datadir=/usr/local/Cellar/gdb/7.11/share/gdb (relocatable)
--with-jit-reader-dir=/usr/local/Cellar/gdb/7.11/lib/gdb (relocatable)
--with-separate-debug-dir=/usr/local/Cellar/gdb/7.11/lib/debug (relocatable)

The version of my OS is OS X Yosemite 10.10.5

$ uname -a
Darwin 14.5.0 Darwin Kernel Version 14.5.0: Mon Jan 11 18:48:35 PST 2016; root:xnu-2782.50.2~1/RELEASE_X86_64 x86_64
Comment 1 Pedro Alves 2016-05-02 21:55:19 UTC
I'm clueless on the darwin/osx debug API, but it sounds like gdb is never notified of the SIGINT.  "set debug darwin 1" and "set debug infrun 1" may reveal something.  The darwin target code is in darwin-nat.c, if you want to take a look yourself.