On Thu, 2013-10-24 at 21:54 +0200, Jan Kratochvil wrote:
> Looks good. Only slightly concerned about the missing SIGSTOP
Thanks for your research and explanation.
Sad it is needed. But good we understand why now.
+ if (linux_proc_pid_is_stopped (tid))
+ /* See gdb/linux-nat.c linux_nat_post_attach_wait. */
+ syscall (__NR_tkill, tid, SIGSTOP);
+ ptrace (PTRACE_CONT, tid, NULL, NULL);
I do think you should add a bit more comment here. Not everybody will
have gdb sources handy. Just something like:
/* Make sure there is a SIGSTOP signal pending even when the process is
already STOPPED. Older kernels might fail to generate a SIGSTOP in
that case in response to our PTRACE_ATTACH above. Which would make
the waitpid below wait forever. So emulate it. Since there can
only be one SIGSTOP pending this is safe.
See also gdb/linux-nat.c linux_nat_post_attach_wait. */
It is a pity we have to do this check always. If there was a way to
detect buggy kernels once that would be great. But I don't see how.
Patch looks good.