aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-fork.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2006-03-10 20:15:42 +0000
committerMichael Snyder <msnyder@vmware.com>2006-03-10 20:15:42 +0000
commit56aac7e845ae80033d534869791f105cc62ba77d (patch)
tree59fb6905fc455ffea0258d4f9c376bcebe0a5b70 /gdb/linux-fork.c
parent3a4a14e9ea1af8d2e5f0d54452be81ccc19c9a1a (diff)
downloadgdb-56aac7e845ae80033d534869791f105cc62ba77d.zip
gdb-56aac7e845ae80033d534869791f105cc62ba77d.tar.gz
gdb-56aac7e845ae80033d534869791f105cc62ba77d.tar.bz2
2006-03-09 Michael Snyder <msnyder@redhat.com>
* linux-nat.c (kill_inferior): Just call target_mourn_inferior instead of getting tricky for the multi-fork case. * linux-fork.c (linux_fork_killall): Call PT_KILL and waitpid for each fork, and then use init_fork_list to delete them.
Diffstat (limited to 'gdb/linux-fork.c')
-rw-r--r--gdb/linux-fork.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 768c7da..f024490 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -72,8 +72,7 @@ add_fork (pid_t pid)
{
struct fork_info *fp;
- if (fork_list == NULL &&
- pid != PIDGET (inferior_ptid))
+ if (fork_list == NULL && pid != PIDGET (inferior_ptid))
{
/* Special case -- if this is the first fork in the list
(the list is hitherto empty), and if this new fork is
@@ -322,17 +321,22 @@ linux_fork_killall (void)
status for it) -- however any process may be a child
or a parent, so may get a SIGCHLD from a previously
killed child. Wait them all out. */
+ struct fork_info *fp;
pid_t pid, ret;
int status;
- do {
- pid = PIDGET (fork_list->ptid);
- do {
- ptrace (PT_KILL, pid, 0, 0);
- ret = waitpid (pid, &status, 0);
- } while (ret == pid && WIFSTOPPED (status));
- delete_fork (fork_list->ptid);
- } while (fork_list != NULL);
+ for (fp = fork_list; fp; fp = fp->next)
+ {
+ pid = PIDGET (fp->ptid);
+ do {
+ ptrace (PT_KILL, pid, 0, 0);
+ ret = waitpid (pid, &status, 0);
+ /* We might get a SIGCHLD instead of an exit status. This is
+ aggravated by the first kill above - a child has just
+ died. MVS comment cut-and-pasted from linux-nat. */
+ } while (ret == pid && WIFSTOPPED (status));
+ }
+ init_fork_list (); /* Clear list, prepare to start fresh. */
}
/* The current inferior_ptid has exited, but there are other viable