From owner-freebsd-hackers Mon Jun 10 13:33: 9 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.openet-telecom.com (mail.openet-telecom.com [62.17.151.60]) by hub.freebsd.org (Postfix) with ESMTP id D26BC37B403 for ; Mon, 10 Jun 2002 13:33:05 -0700 (PDT) Received: from gpo.openet-telecom.lan (unverified) by mail.openet-telecom.com (Content Technologies SMTPRS 4.2.1) with ESMTP id ; Mon, 10 Jun 2002 21:44:56 +0100 Received: from openet-telecom.com (10.0.0.40) by gpo.openet-telecom.lan (NPlex 6.5.007) id 3CF373520000A9F6; Mon, 10 Jun 2002 21:29:51 +0100 Message-ID: <3D050CFB.A9A74AF9@openet-telecom.com> Date: Mon, 10 Jun 2002 21:33:00 +0100 From: Peter Edwards X-Mailer: Mozilla 4.79 [en] (X11; U; Linux 2.4.2 i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Cc: pmedwards@eircom.net Subject: interaction between wait(2), ptrace(2), and rfork(2) with flags |= RFLINUXTHPN Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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