Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 May 2001 12:54:10 +0000 (GMT)
From:      diman <diman@asd-g.com>
To:        Jiangyi Liu <gzjyliu@public.guangzhou.gd.cn>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Weird PT_DETACH
Message-ID:  <Pine.BSF.4.21.0105301250460.202-100000@portal.none.ua>
In-Reply-To: <878zjf0zvr.fsf@fatcow.home>

next in thread | previous in thread | raw e-mail | index | archive | help


	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 <unistd.h>
> #include <sys/types.h>
> #include <sys/ptrace.h>
> 
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0105301250460.202-100000>