tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ptrace code crash (now for real)



Now with a shorter example

Why does this crash?
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int main(int argc, const char *argv[])
{	   
	int pid, ppid;

	pid = fork();

	if (pid == 0) {
		ppid = getppid();
		if (ptrace(PT_ATTACH, ppid, NULL, 0) == 0) {
			printf("PT_ATTACH success\n");
			waitpid(ppid, NULL, 0);
			ptrace(PT_DETACH, ppid, NULL, 0);
		}
	} else {
//		waitpid(pid, NULL, 0);
	}

	sleep(1);
	return 0;
}


Home | Main Index | Thread Index | Old Index