Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Jun 2002 21:33:00 +0100
From:      Peter Edwards <peter.edwards@openet-telecom.com>
To:        freebsd-hackers@freebsd.org
Cc:        pmedwards@eircom.net
Subject:   interaction between wait(2), ptrace(2), and rfork(2) with flags |=  RFLINUXTHPN
Message-ID:  <3D050CFB.A9A74AF9@openet-telecom.com>

next in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D050CFB.A9A74AF9>