[patch] Fix Linux attach to signalled/stopped processes

Roland McGrath roland@redhat.com
Fri Apr 11 08:46:00 GMT 2008


> 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.

To be pedantic about it: a SIGSTOP is generated, but causes no wakeup or
delivery for ptrace to see (because it's already stopped).  You can see
the SIGSTOP pending in /proc/pid/status.  Generating a SIGCONT clears
any pending stop signals, so normally it's as if it never existed.  But,
I think if you were to do PTRACE_CONT,pid,0,0 you would make it wake up,
dequeue the new SIGSTOP and then report to you for wait/SIGCHLD.  And
since PTRACE_CONT would give ESRCH if it weren't stopped yet, you might
be able to do PTRACE_ATTACH;PTRACE_CONT;wait reliably.  But don't hold
me to it.


Thanks,
Roland



More information about the Gdb-patches mailing list