From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29814 invoked by alias); 10 May 2010 19:31:34 -0000 Received: (qmail 29804 invoked by uid 22791); 10 May 2010 19:31:33 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 May 2010 19:31:27 +0000 Received: from mailhost2.vmware.com (mailhost2.vmware.com [10.16.67.167]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id D5FBA1000E; Mon, 10 May 2010 12:31:25 -0700 (PDT) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost2.vmware.com (Postfix) with ESMTP id CBEEB8E677; Mon, 10 May 2010 12:31:25 -0700 (PDT) Message-ID: <4BE85F0D.1090807@vmware.com> Date: Mon, 10 May 2010 19:31:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.22 (X11/20090609) MIME-Version: 1.0 To: Hui Zhu CC: gdb-patches ml Subject: Re: [RFA] Checkpoint: wait the defunct process when delete it References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2010-05/txt/msg00228.txt.bz2 Hui Zhu wrote: > Hi, > > I found that when we delete the checkpoint process, it keep defunct. > This is because the parent process is still running and didn't wait > it. > So I add a wait_ptid function after ptrace kill. > > Please help me review it. I think it should be called something more informative than "wait_ptid". The name should reflect the fact that it is actually the inferior that is calling wait, not gdb. Something like "inferior_call_wait_ptid", perhaps. Other than that it seems like a good idea... > 2010-05-09 Hui Zhu > > * linux-fork.c (wait_ptid): New function. > (delete_checkpoint_command): Call wait_ptid. > > > --- > linux-fork.c | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > --- a/linux-fork.c > +++ b/linux-fork.c > @@ -410,6 +410,35 @@ linux_fork_detach (char *args, int from_ > delete_fork (inferior_ptid); > } > > +static int > +wait_ptid (ptid_t ptid) > +{ > + struct objfile *waitpid_objf; > + struct value *waitpid_fn = NULL; > + struct value *argv[4]; > + struct gdbarch *gdbarch = get_current_arch (); > + > + /* Get the waitpid_fn. */ > + if (lookup_minimal_symbol ("waitpid", NULL, NULL) != NULL) > + waitpid_fn = find_function_in_inferior ("waitpid", &waitpid_objf); > + if (!waitpid_fn) > + if (lookup_minimal_symbol ("_waitpid", NULL, NULL) != NULL) > + waitpid_fn = find_function_in_inferior ("waitpid", &waitpid_objf); > + if (!waitpid_fn) > + return -1; > + > + /* Get the argv. */ > + argv[0] = value_from_longest (builtin_type (gdbarch)->builtin_int, > PIDGET (ptid)); > + argv[1] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); > + argv[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); > + argv[3] = 0; > + > + if (call_function_by_hand (waitpid_fn, 3, argv) == 0) > + return -1; > + > + return 0; > +} > + > /* Fork list <-> user interface. */ > > static void > @@ -431,6 +460,9 @@ Please switch to another checkpoint befo > if (ptrace (PTRACE_KILL, PIDGET (ptid), 0, 0)) > error (_("Unable to kill pid %s"), target_pid_to_str (ptid)); > > + if (wait_ptid (ptid)) > + error (_("Unable to wait pid %s"), target_pid_to_str (ptid)); > + > if (from_tty) > printf_filtered (_("Killed %s\n"), target_pid_to_str (ptid));