From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9342 invoked by alias); 27 Nov 2011 22:23:17 -0000 Received: (qmail 9333 invoked by uid 22791); 27 Nov 2011 22:23:17 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-qy0-f169.google.com (HELO mail-qy0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Nov 2011 22:23:02 +0000 Received: by qyg14 with SMTP id 14so1247728qyg.0 for ; Sun, 27 Nov 2011 14:23:02 -0800 (PST) Received: by 10.229.61.142 with SMTP id t14mr4539796qch.37.1322432582064; Sun, 27 Nov 2011 14:23:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.61.142 with SMTP id t14mr4539791qch.37.1322432581938; Sun, 27 Nov 2011 14:23:01 -0800 (PST) Received: by 10.224.86.208 with HTTP; Sun, 27 Nov 2011 14:23:01 -0800 (PST) In-Reply-To: <20111127204011.GA4606@host1.jankratochvil.net> References: <20111124000052.14DC12461B1@ruffy.mtv.corp.google.com> <20111127204011.GA4606@host1.jankratochvil.net> Date: Sun, 27 Nov 2011 22:23:00 -0000 Message-ID: Subject: Re: [RFC] Don't immediately SIGTERM the child of "target remote |". From: Doug Evans To: Jan Kratochvil Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2011-11/txt/msg00751.txt.bz2 On Sun, Nov 27, 2011 at 12:40 PM, Jan Kratochvil wrote: > On Thu, 24 Nov 2011 01:00:51 +0100, Doug Evans wrote: > [...] >> - =A0 =A0 =A0int status; >> - =A0 =A0 =A0kill (state->pid, SIGTERM); >> + =A0 =A0 =A0int rc, status; >> + =A0 =A0 =A0void (*ofunc) (); =A0 =A0 =A0/* Previous SIGALRM handler. = =A0*/ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^int (or void) >> + >> + =A0 =A0 =A0/* Don't kill the task right away, give it a chance to shut= down cleanly. >> + =A0 =A0 =A0But don't wait forever though. =A0*/ >> +#if defined (HAVE_SIGACTION) && defined (SA_RESTART) >> + =A0 =A0 =A0{ >> + =A0 =A0 struct sigaction sa, osa; >> + =A0 =A0 sa.sa_handler =3D sigalrm_handler; >> + =A0 =A0 sigemptyset (&sa.sa_mask); >> + =A0 =A0 sa.sa_flags =3D 0; >> + =A0 =A0 sigaction (SIGALRM, &sa, &osa); >> + =A0 =A0 ofunc =3D osa.sa_handler; >> + =A0 =A0 =A0} >> +#else >> + =A0 =A0 =A0ofunc =3D (void (*)()) signal (SIGALRM, sigalrm_handler); >> +#endif > [...] >> + =A0 =A0 =A0alarm (0); >> + =A0 =A0 =A0signal (SIGALRM, ofunc); > > You should restore OSA, not just OFUNC. The code was borrowed from remote-sim.c. In this case I suspect it doesn't matter, but it's just as well to restore = osa.