From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9726 invoked by alias); 26 Jul 2004 19:13:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9719 invoked from network); 26 Jul 2004 19:13:55 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 26 Jul 2004 19:13:55 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i6QJDte3032006 for ; Mon, 26 Jul 2004 15:13:55 -0400 Received: from localhost.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i6QJDra14281; Mon, 26 Jul 2004 15:13:54 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id DED1E2B9D; Mon, 26 Jul 2004 15:13:47 -0400 (EDT) Message-ID: <410557EB.1020904@gnu.org> Date: Mon, 26 Jul 2004 19:13:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: Ashley Pittman Cc: gdb-patches@sources.redhat.com Subject: [commit/6.2] Detach when in batch mode; Was: Clean shutdown if still attached at exit in batch mode References: <1083244544.10141.209.camel@ashley> In-Reply-To: <1083244544.10141.209.camel@ashley> Content-Type: multipart/mixed; boundary="------------090007020908070409000506" X-SW-Source: 2004-07/txt/msg00373.txt.bz2 This is a multi-part message in MIME format. --------------090007020908070409000506 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1694 > Hi, > > I've been hitting some problems running gdb against live processes on > ia64 nodes, often stack traces are incomplete due to signal handler > issues or such like. If running gdb interactively then gdb drops back > to the prompt and everything is fine but if run in batch mode it stops > parsing the batch file and exits. > > The problem here is that it does not detach before quiting so the > process becomes a zombie. Attached is a patch to prevent this. I've committed the attached (mainline and 6.2). Even when the script didn't abort GDB would kill the attached inferior :-( As for getting GDB to return a non-zero exit when the batch script fails - yes but it is a separate bug. We'd need to record that the script failed and exit non-zero based on that. Andrew > Ashley, > > *** gdb-6.1/gdb/main.c 2004-02-18 00:21:00.000000000 +0000 > --- gdb-6.1-modified/gdb/main.c 2004-04-29 14:10:17.000000000 +0100 > *************** > *** 736,742 **** > init_history (); > > if (batch) > ! { > /* We have hit the end of the batch file. */ > exit (0); > } > --- 736,752 ---- > init_history (); > > if (batch) > ! { > ! if ( attach_flag) { > ! /* If there is a problem executing the command in the batch file > ! * then we might not have parsed all of it and might be attached. > ! * Simply calling exit() would leave zombies so be nice and detach > ! * but let the user know that there was a problem. > ! */ > ! target_detach(NULL,0); > ! exit(1); > ! } > ! > /* We have hit the end of the batch file. */ > exit (0); > } --------------090007020908070409000506 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 852 2004-07-26 Andrew Cagney Problem reported by Ashley Pittman . * main.c (captured_main): When in batch mode always detach. Index: main.c =================================================================== RCS file: /cvs/src/src/gdb/main.c,v retrieving revision 1.42 diff -p -u -r1.42 main.c --- main.c 17 Jul 2004 03:25:10 -0000 1.42 +++ main.c 26 Jul 2004 19:00:46 -0000 @@ -729,6 +729,13 @@ extern int gdbtk_test (char *); if (batch) { + if (attach_flag) + /* Either there was a problem executing the command in the + batch file aborted early, or the batch file forgot to do an + explicit detach. Explicitly detach the inferior ensuring + that there are no zombies. */ + target_detach (NULL, 0); + /* We have hit the end of the batch file. */ exit (0); } --------------090007020908070409000506--