This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Handle SIGINT in Python
- From: Doug Evans <dje at google dot com>
- To: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 10 Jan 2012 13:46:31 -0800
- Subject: Re: Handle SIGINT in Python
- References: <A8DAE02C-D489-4C5A-A4C5-6D898A0D8A9F@cs.umd.edu>
On Tue, Jan 10, 2012 at 1:29 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
> Hi,
>
> I've written a patch to GDB's Python support to allow SIGINT to interrupt a running script to address the bug http://sourceware.org/bugzilla/show_bug.cgi?id=13265 (I've attached my patch to that page).
>
> It works by installing a Python-specific SIGINT handler just before executing a Python script, and restoring the original SIGINT handler after execution as well as at calls to gdb.execute(...).
>
> There's one caveat: if an inferior is running via, e.g., gdb.execute("run"), SIGINT will interrupt the inferior but not the enclosing "python" command. I think it would be better to also interrupt the "python" command, but I'm not sure how to detect this case yet.
There is value in having the SIGINT *only* affect the inferior.
It's up to the script to handle the various reasons why the inferior
may have stopped, and you don't (generally) want to interfere with
that (by interrupting the script too).