Re: [patch] Fix Linux attach to signalled/stopped processes

Jan Kratochvil
2008-04-10T15:30:54Z

On Thu, 10 Apr 2008 17:15:45 +0200, Daniel Jacobowitz wrote:
> On Tue, Apr 01, 2008 at 03:49:36PM -0700, Roland McGrath wrote:
...
> > As a gdb user, I have long been annoyed by the behavior on attaching to a
> > stopped process. What I want is for attach to complete immediately and let
> > me examine the process. If I then "cont", the process should go back to
> > what it was doing--sitting in job control stop. Then fg or otherwise
> > sending SIGCONT will wake it up normally, and gdb should stop and tell me
> > about the SIGCONT like normal.
>
> How could GDB put an attached process back into job control stop?

ptrace (PTRACE_DETACH, child_pid, NULL, (void *) (long) SIGSTOP);

It is being done by the patch (in the appropriate cases)
http://cvs.fedora.redhat.com/viewcvs/*checkout*/rpms/gdb/devel/gdb-6.7-bz233852-attach-signalled-fix.patch
(this patch does not follow the Roland's suggested behavior)

The current GDB code already interprets the DETACH_COMMAND ARGS parameter as
the signal number for PTRACE_DETACH but one cannot enter any arguments for the
`detach' command by the cli interface.

Regards,
Jan