From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16305 invoked by alias); 16 Nov 2005 16:54:38 -0000 Received: (qmail 16289 invoked by uid 22791); 16 Nov 2005 16:54:35 -0000 Received: from fra-del-02.spheriq.net (HELO fra-del-02.spheriq.net) (195.46.51.98) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 16 Nov 2005 16:54:35 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-02.spheriq.net with ESMTP id jAGGro1w016754 for ; Wed, 16 Nov 2005 16:53:50 GMT Received: from fra-cus-02.spheriq.net (fra-cus-02.spheriq.net [195.46.51.38]) by fra-out-01.spheriq.net with ESMTP id jAGGro9e024521 for ; Wed, 16 Nov 2005 16:53:50 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-02.spheriq.net with ESMTP id jAGGrefh026274 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Wed, 16 Nov 2005 16:53:45 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9209DDA4A for ; Wed, 16 Nov 2005 16:53:36 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 5C3E247493; Wed, 16 Nov 2005 16:56:35 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1DEA675969 for ; Wed, 16 Nov 2005 16:56:35 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A9AFB4746B for ; Wed, 16 Nov 2005 16:56:34 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CGZ38899 (AUTH "andrew stubbs"); Wed, 16 Nov 2005 16:53:34 GMT Message-ID: <437B6374.1@st.com> Date: Wed, 16 Nov 2005 19:29:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [PATCH] SIGTERM handler Content-Type: multipart/mixed; boundary="------------080603060502090007020205" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.1.07 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00239.txt.bz2 This is a multi-part message in MIME format. --------------080603060502090007020205 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 351 Hi, This patch adds a handler for SIGTERM. The main purpose is to ensure that GDB quit through quit_force() and therefore properly disconnects from the target. This is quite important for our target interface and should do no harm for anybody else's. It also ensures that --return-child-result works when GDB exits this way. Thanks Andrew Stubbs --------------080603060502090007020205 Content-Type: text/plain; name="sigterm.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sigterm.patch" Content-length: 1704 2005-11-16 Andrew Stubbs * event-top.h (async_init_signals): Add SIGTERM handler. (handle_sigterm): New function. * event-top.h (handle_sigterm): New prototype. Index: src/gdb/event-top.c =================================================================== --- src.orig/gdb/event-top.c 2005-11-09 12:02:37.000000000 +0000 +++ src/gdb/event-top.c 2005-11-09 12:03:22.000000000 +0000 @@ -892,6 +892,7 @@ async_init_signals (void) signal (SIGINT, handle_sigint); sigint_token = create_async_signal_handler (async_request_quit, NULL); + signal (SIGTERM, handle_sigterm); /* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed to the inferior and breakpoints will be ignored. */ @@ -964,6 +965,15 @@ handle_sigint (int sig) mark_async_signal_handler_wrapper (sigint_token); } +/* Quit GDB if SIGTERM is received. + GDB would quit anyway, but this way it will clean up properly. */ +void +handle_sigterm (int sig) +{ + signal (sig, handle_sigterm); + quit_force ((char *) 0, stdin == instream); +} + /* Do the quit. All the checks have been done by the caller. */ void async_request_quit (gdb_client_data arg) Index: src/gdb/event-top.h =================================================================== --- src.orig/gdb/event-top.h 2003-04-12 18:41:25.000000000 +0100 +++ src/gdb/event-top.h 2005-11-09 12:02:44.000000000 +0000 @@ -97,6 +97,7 @@ extern void handle_stop_sig (int sig); #endif #endif extern void handle_sigint (int sig); +extern void handle_sigterm (int sig); extern void pop_prompt (void); extern void push_prompt (char *prefix, char *prompt, char *suffix); extern void gdb_readline2 (void *client_data); --------------080603060502090007020205--