From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4018 invoked by alias); 13 May 2010 10:31:18 -0000 Received: (qmail 4007 invoked by uid 22791); 13 May 2010 10:31:17 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,TW_TP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 May 2010 10:31:12 +0000 Received: (qmail 27828 invoked from network); 13 May 2010 10:31:10 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 May 2010 10:31:10 -0000 From: Pedro Alves To: Hui Zhu Subject: Re: [RFA] Checkpoint: wait the defunct process when delete it Date: Thu, 13 May 2010 11:50:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-21-generic; KDE/4.3.2; x86_64; ; ) Cc: Michael Snyder , "gdb-patches@sourceware.org" References: <201005121937.44287.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005131130.57597.pedro@codesourcery.com> 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/msg00271.txt.bz2 On Thursday 13 May 2010 08:58:49, Hui Zhu wrote: > >> 2. before call "inferior_call_waitpid" to waitpid the ptid. > >> Check if ppid is a simple thread. ppid > 1 > >> Check if ppid is the GDB. If ppid is GDB, it will auto wait the ptid. > > > > What do you mean, it will auto wait the ptid? AFAICS, > > > > (gdb) checkpoint > > (gdb) checkpoint > > (gdb) checkpoint > > (gdb) checkpoint > > (gdb) checkpoint > > (gdb) restart 5 > > (gdb) delete checkpoint 0 > > > > will still leave checkpoint 0 zombie? > > This is because the parent of checkpoint is GDB. GDB will auto wait > the zombie, so I just leave them there let GDB hanle it. You didn't answer the question. Please point me at where is this "gdb auto waiting". I actually don't understand that rationale. The `init' process will "auto wait" the checkpoint forks as well, so why bother in the first place then? > + if ((!find_thread_ptid (fi->parent_ptid) && find_fork_ptid (fi->parent_ptid)) > + || (find_thread_ptid (fi->parent_ptid) && is_stopped (fi->parent_ptid))) This requires an explaning comment in the code. > >> + > >> + ret = call_function_by_hand (getppid_fn, 0, NULL); > >> + if (ret == 0) > >> + return ppid; > > > > ??? can getppid really return 0 ? > > This 0 is not the return value of getppid. Oh, right. :-) > This is how function "checkpoint_command" use this function. Check it > just for code safe. :) > ret = call_function_by_hand (fork_fn, 0, &ret); > do_cleanups (old_chain); > if (!ret) /* Probably can't happen. */ > error (_("checkpoint: call_function_by_hand returned null.")); Well, the only return from call_function_by_hand does: gdb_assert (retval); return retval; All other cases are handled by throwing an error. So "definitely can't happen"; please remove the new dead code you're adding. BTW, you patch is not error/exception safe. You didn't consider the case of an `error' being thrown between switching the fork and back. Otherwise, the patch looks good. -- Pedro Alves