Ptrace segfault

Gunnar Hinriksson tomtinn at gmail.com
Thu Apr 29 19:36:46 UTC 2010


Hello

Im having a little problem using ptrace on my system.
If I use ptrace to attach to another process the child process
segfaults once I detach.
For example using this simple program.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>

int main(int argc, char *argv[])
{
        int pid = atoi(argv[1]);
        ptrace(PT_ATTACH, pid, 0, 0);
        wait(NULL);
        ptrace(PT_DETACH, pid, 0, 0);
        return 0;
}

Am I using ptrace incorrectly or is there perhaps a bug in ptrace that
causes the child to always segfault ?

With Regards

Gunnar

FreeBSD knut 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Apr 27
04:36:16 UTC 2010     gunnar at knut:/usr/obj/usr/src/sys/GENERIC  amd64


More information about the freebsd-hackers mailing list