From owner-freebsd-hackers Wed May 30 5:58:10 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from sivka.carrier.kiev.ua (sivka.carrier.kiev.ua [193.193.193.101]) by hub.freebsd.org (Postfix) with ESMTP id 7776E37B423 for ; Wed, 30 May 2001 05:57:58 -0700 (PDT) (envelope-from diman@asd-g.com) Received: from core.is.kiev.ua (p187.is.kiev.ua [62.244.5.187] (may be forged)) by sivka.carrier.kiev.ua (8/Kilkenny_is_better) with ESMTP id PWG39786; Wed, 30 May 2001 15:57:48 +0300 (EEST) (envelope-from diman@asd-g.com) Received: from [10.203.1.10] ([10.203.1.10]) by core.is.kiev.ua (8.11.1/ASDG-2.3-NR) with ESMTP id f4UCviM33635; Wed, 30 May 2001 15:57:44 +0300 (EEST) (envelope-from diman@asd-g.com) Date: Wed, 30 May 2001 12:54:10 +0000 (GMT) From: diman X-Sender: diman@portal.none.ua To: Jiangyi Liu Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Weird PT_DETACH In-Reply-To: <878zjf0zvr.fsf@fatcow.home> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 To attach debugger to a process please use PT_ATTACH request instead of PT_DETACH. Use PT_DETACH to stop debugging a process and leave it alone. On 30 May 2001, Jiangyi Liu wrote: > Hi all, > > The ptrace(2) man page is probably outdated. I used PT_DETACH in the > following code, but it didn't run ./test. I also tried to use > ptrace(PT_DETACH, pid, (caddr_t)1, 0) to detach, but it failed too. > > BTW, if I omit wait(0) and ptrace(PT_DETACH, ...) in the code, after > it runs there is a process sticking to the system. Even kill -9 can't > kill it. > > $ ps aux | grep jyliu > ... > jyliu 423 0.0 0.1 216 100 p2 TX 7:41AM 0:00.00 (test) > ... > $ kill -9 423 > $ ps aux | grep jyliu > ... > jyliu 423 0.0 0.1 216 100 p2 TX 7:41AM 0:00.00 (test) > ... > > So it's still there. Quite funny. Any clue? > > Jiangyi > > ---code begins here > #include > #include > #include > > int main() > { > pid_t pid; > > if(!(pid=fork())) { > /* child */ > ptrace(PT_TRACE_ME, 0, 0, 0); > puts("child speaking"); > execve("./test", NULL, NULL); > } else { > wait(0); > ptrace(PT_DETACH, pid, 0, 0); > exit(0); > } > } > ---code ends here > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message