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 [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to