Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Checkpoint: wait the defunct process when delete it
@ 2010-05-09  6:23 Hui Zhu
  2010-05-10 19:31 ` Michael Snyder
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Hui Zhu @ 2010-05-09  6:23 UTC (permalink / raw)
  To: gdb-patches ml; +Cc: Michael Snyder

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.

Thanks,
Hui

2010-05-09  Hui Zhu  <teawater@gmail.com>

	* 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));


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-05-18  2:49 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-09  6:23 [RFA] Checkpoint: wait the defunct process when delete it Hui Zhu
2010-05-10 19:31 ` Michael Snyder
2010-05-10 23:30 ` Pedro Alves
2010-05-11 21:50   ` Michael Snyder
2010-05-11 22:28     ` Michael Snyder
2010-05-12  0:02     ` Pedro Alves
2010-05-11 22:43 ` Michael Snyder
2010-05-12  0:05   ` Pedro Alves
2010-05-12  0:27     ` Michael Snyder
2010-05-12  4:19       ` Hui Zhu
2010-05-12 18:39         ` Pedro Alves
2010-05-12 18:57           ` Pedro Alves
2010-05-13  9:11           ` Hui Zhu
2010-05-13 11:50             ` Pedro Alves
2010-05-14 11:05               ` Hui Zhu
2010-05-14 14:43                 ` Pedro Alves
2010-05-14 15:08                   ` Hui Zhu
2010-05-14 16:19                     ` Pedro Alves
2010-05-17  6:41                       ` Hui Zhu
2010-05-17 10:45                         ` Pedro Alves
2010-05-18 17:18                           ` Hui Zhu
2010-05-14 19:29                     ` Michael Snyder
2010-05-17  8:11                       ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox