From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31876 invoked by alias); 12 Jan 2012 16:48:18 -0000 Received: (qmail 31860 invoked by uid 22791); 12 Jan 2012 16:48:14 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ausc60pc101.us.dell.com (HELO ausc60pc101.us.dell.com) (143.166.85.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 16:48:01 +0000 X-Loopcount0: from 10.175.216.251 From: To: , CC: , , Date: Thu, 12 Jan 2012 16:48:00 -0000 Subject: RE: Handle SIGINT in Python Message-ID: <09787EF419216C41A903FD14EE5506DD030F1EB37E@AUSX7MCPC103.AMER.DELL.COM> References: In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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/msg00408.txt.bz2 >just my 2 cents to the discussion. >[I'm not sure I could follow all the arguments, so my comments are based o= n Khoo's patch] > >+static void >+gdbpy_handle_sigint (int sig) >+{ >+ PyErr_SetInterrupt (); >+} > >I would be quite afraid if GDB could throw an KeyboardInterruptException i= n any call to its API, there wouldn't be any way to ensure internal consist= ency inside the script, except with try_catch surrounding every GDB functio= n call ... Of course, but that is exactly what you want. In any Python script, if you= need to handle interrupts for proper operation, you wrap the critical sect= ion in a try..except block. If not, then you don't. There is nothing new = or different here in the GDB case. Any Python statement can throw a Keyboa= rdException. The only difference is in what happens when you get to the top of a Python = script with a KeyboardInterrupt exception and no one is catching it. In an= interactive session (python shell) you get a backtrace. I think in a Pyth= on interactive session inside GDB ("python" command with no arguments) the = same should be true. In a script invocation from the command shell (outsid= e GDB) you'd also get a traceback in this case. In GDB, you probably shoul= d not, as was discussed earlier; in that case, the interrupt should be pass= ed up to the GDB common machinery to handle exactly as it would handle an i= nterrupt for any other command, without a Python style traceback printout. paul