This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Daniel, thread vs. fork question.
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Michael Snyder <msnyder at redhat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Wed, 10 Mar 2004 20:51:26 -0500
- Subject: Re: Daniel, thread vs. fork question.
- References: <404FBC18.4090909@redhat.com>
On Thu, Mar 11, 2004 at 01:08:40AM +0000, Michael Snyder wrote:
> Hey Daniel,
>
> Got a question concerning the code in
> linux-nat.c::linux_handle_extended_wait.
>
> You've got a PTRACE_EVENT_FORK event, and now you're going to call
> waitpid. You pull a pid out of a list of stopped pids, and wait for
> it using waitpid. In your comment, you explain that you don't have to
> worry about the pid being a clone, because you didn't ask for pids in
> the event mask.
>
> But how is this affected by threads, especially NPTL threads?
> I've got a fairly simple test-case (modified from pthreads.c,
> I'll attach it), in which a child thread calls fork -- but gdb
> apparently tries to wait on the main thread (or perhaps the most
> recent event thread). Since that's not the thread that called
> fork, waitpid returns -1 with "no child". Gdb reports:
> waiting for new child: No child processes.
>
> FWIW, I've tried this on both a single-processor and an SMP machine.
No attachment? Also, what glibc/nptl version are you using.
It's entirely possible that I didn't handle some threaded case. But we
save the PID that we plan to wait on, which should be the child thread,
so I don't see how what you're describing can happn.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer