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