Skip site navigation (1)Skip section navigation (2)
Date:      31 May 2001 14:57:11 +0800
From:      Jiangyi Liu <gzjyliu@public.guangzhou.gd.cn>
To:        diman@asd-g.com (diman)
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: Weird PT_DETACH
Message-ID:  <878zjerooo.fsf@fatcow.home>
In-Reply-To: <Pine.BSF.4.21.0105301420150.201-100000@portal.none.ua>
References:  <006a01c0e911$96e68720$a701160a@fatcow> <Pine.BSF.4.21.0105301420150.201-100000@portal.none.ua>

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

I tried to use (caddr_t)1 in PT_DETACH, but the code just
failed. I'm confused. It just seems the execve is stopped. Maybe I'd read
through the kernel source code to figure out where the problem is.

Jiangyi

diman@asd-g.com (diman) writes:

> 	Hope your program not named "./test"  ??
> 	I changed it to /bin/sh and it works just fine.
> 	It was hard to debug due to my own proggie bug :)
> 	bb.
> 
> 
> #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, (caddr_t)1, 0); <---------- also
>          exit(0);
>      }
> }
> 
> 
> 
> 
> 
> On Wed, 30 May 2001, Jiangyi Liu wrote:
> 
> > 
> > > 
> > > If i understand ptrace(2) manual page correctly,
> > > you should use 
> > > ptrace(PT_DETACH,pid,(caddr_t)1,0)
> > > instead of 
> > > ptrace(PT_DETACH,pid,0,0) .
> > > 
> > 
> > If you read my first post again, you will know that indeed I've tried to use (caddr_t)1 but failed too.
> > 
> > > BTW you code is *very hard to debug* on my 4.1.1 :)
> > > What your uname -a tells you?
> > 
> > Why? My box is 4.3-STABLE.
> > 
> > Jiangyi
> > 
> 
> 
> 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?878zjerooo.fsf>