Hi,
kern_exit.c:wait1() has the following lines in -STABLE:

>  if ((p->p_sigparent != SIGCHLD) ^ ((uap->options & WLINUXCLONE) != 0))
>          continue;

As it is, if you ptrace(PT_ATTACH) to a process started with
rfork(flags|RFLINUXTHPN), and do a waitpid() as you normally would, this
causes waitpid() to fail with ECHILD, because the original parent/child
relationship doesn't hold, and the debugger doesn't know that the
debugee was started in this fashion. This can also mean that the
ptrace(PT_DETACH) ends up killing the process, because you can't
guarantee that it is stopped by the time you get to do the
ptrace(PT_DETACH).

In order to allow existing ptrace(2)-using programs to attach to such
processes, would the following be more appropriate?

> if ((p->p_sigparent != SIGCHILD && (p->p_flag & PTRACED) == 0) ^
>     ((uap->options & WLINUXCLONE) != 0))

(BTW: Why "^" rather than "!=" ? I would have thought a boolean operator
more natural here.)

Cheers,
Peter.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to