[PATCH 2/4]: Handle SIGINT under Python by raising KeyboardInterrupt

Khoo Yit Phang khooyp@cs.umd.edu
Tue Jul 31 21:45:00 GMT 2012


Hi,

On Jul 31, 2012, at 9:58 AM, Tom Tromey wrote:

>>>>>> "Yit" == Khoo Yit Phang <khooyp@cs.umd.edu> writes:
> 
> I am wondering if the appended patch is correct.
> It removes the check of immediate_quit from async_request_quit.
> It also changes all the places that set immediate_quit to immediately
> call QUIT afterward; the idea being that this handles the race
> situation.  It also changes prompt_for_continue to use quit rather than
> a call to async_request_quit, which has the same effect but doesn't rely
> on the handling of immediate_quit.

It does look like the check for immediate_quit was put in to handle the call to async_request_quit inside prompt_for_continue (http://thread.gmane.org/gmane.comp.gdb.devel/18975), so it seems correct to me. This patch, with your other patch, solves the SIGINT problem in Python and GDB as far as I can tell, and works with my Python readline patch (after removing the calls to suspend_sigint_handler from my other patch).

Just to clarify about QUIT just after immediate_quit, is it to handle Ctrl-C that occurs before immediate_quit, where it would not have triggered before this patch (and simply left a quit event in the event queue)?

> A couple notes though...
> 
> First, it seems to me that immediate_quit and quit_flag ought to be
> of type sig_atomic_t.  And, immediate_quit should be set and cleared,
> not incremented and decremented.  I assume these aren't really needed in
> practice, they are just pedantically more correct.

What about making a cleanup-based interface for immediate_quit? This would ensure that correctly scoped use of immediate_quit, assuming that all such uses can be block-scoped.

Yit
July 31



More information about the Gdb-patches mailing list