This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix Linux attach to signalled/stopped processes
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: Doug Evans <dje at google dot com>, GDB Patches <gdb-patches at sourceware dot org>, mark dot kettenis at xs4all dot nl, Roland McGrath <roland at redhat dot com>
- Date: Thu, 10 Apr 2008 17:48:39 +0200
- Subject: Re: [patch] Fix Linux attach to signalled/stopped processes
- References: <e394668d0803311218x35c802c1g7dba5f3b48b38bc8@mail.gmail.com> <20080401223012.GA14076@host0.dyn.jankratochvil.net> <20080410153735.GD21662@caradoc.them.org>
On Thu, 10 Apr 2008 17:37:35 +0200, Daniel Jacobowitz wrote:
> I have another idea to solve the attach problem that does not involve
> redelivering signals - use WNOHANG in the initial wait if /proc
> already shows the process as stopped. There shouldn't be a race if
> this is done after we PTRACE_ATTACH.
You can try it yourself but all the signals take some time to get delivered and
WNOHANG usually misses some signals which should get caught.
> If I run attach-stopped from your testcase in a shell, then send it a
> stop signal using kill from another window, stock GDB fails to attach
> to it - just as I'd expect, that's the bug we're discussing. But if I
> run the attach-stopped.exp test script this part works fine. It turns
> out that if we spawn the program in expect (even at the expect1.1>
> prompt, by hand) instead of using a shell with job control, GDB can
> attach to it just fine.
As the shell already did WAITPID on the process and ate the SIGSTOP
notification so there is no other notification left there for GDB.
A process already stopped does not generate another SIGSTOP during
PTRACE_ATTACH as signals never count.
[ Sure from info from Roland before. ]
Regards,
Jan