From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30661 invoked by alias); 10 Jan 2012 21:46:46 -0000 Received: (qmail 30651 invoked by uid 22791); 10 Jan 2012 21:46:45 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Jan 2012 21:46:32 +0000 Received: by vbbfn1 with SMTP id fn1so46513vbb.0 for ; Tue, 10 Jan 2012 13:46:31 -0800 (PST) Received: by 10.52.68.43 with SMTP id s11mr10343698vdt.46.1326231991410; Tue, 10 Jan 2012 13:46:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.68.43 with SMTP id s11mr10343689vdt.46.1326231991300; Tue, 10 Jan 2012 13:46:31 -0800 (PST) Received: by 10.220.229.1 with HTTP; Tue, 10 Jan 2012 13:46:31 -0800 (PST) In-Reply-To: References: Date: Tue, 10 Jan 2012 21:47:00 -0000 Message-ID: Subject: Re: Handle SIGINT in Python From: Doug Evans To: Khoo Yit Phang Cc: gdb-patches@sourceware.org X-System-Of-Record: true Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00323.txt.bz2 On Tue, Jan 10, 2012 at 1:29 PM, Khoo Yit Phang 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_bu= g.cgi?id=3D13265 (I've attached my patch to that page). > > It works by installing a Python-specific SIGINT handler just before execu= ting a Python script, and restoring the original SIGINT handler after execu= tion 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" comma= nd. 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).