site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com If this is not the case, please file a bug. -- Terry Hi Aron, I think I understand what happens here. Your code actually works, and temporaty resumes the child. The fix is to simply add that portion of code: for (;;) { sleep (1); printf("parent alive\n"); } after your call to ptrace(PT_CONTINUE ) Hope this helps, Thierry Hey guys, #include <sys/types.h> #include <sys/ptrace.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { int pid, status, ret; if((pid = fork()) == 0) { ptrace(PT_TRACE_ME,0,0,0); execl(argv[1],argv[1],0); printf("exec failed\n"); } else{ wait(&status); if(WIFSTOPPED(status)) printf("child has stopped. child pid: %d\n", pid); errno = 0; ret = ptrace(PT_CONTINUE, pid, (caddr_t)1, 0); printf("ret: %d\n", ret); printf("errno: %s\n", strerror(errno)); } } Running output: aronzvis-macbook:ptrace_test aronzvi$ ./ptrace ../voidinc child has stopped. child pid: 37959 ret: 0 errno: Unknown error: 0 I'm running OS X 10.5.7 and building the code with the 10.5 SDK. Your help is much appreciated, Aron-Zvi _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/thierry.bultel%40atempo.co... <thierry_bultel.vcf> _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/tlambert%40apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... The parent exiting should detach the child process, which should be the same as quitting the debugger. On Jul 9, 2009, at 1:04 AM, Thierry bultel wrote: But as the parent immediately exits after, it dies, and causes the child death as well. As a rule, a ptrace based debugger is normally an infinite loop of wait calls ... Aron-Zvi a écrit : I'm trying to get started with basic ptrace functionality with the following:
From my basic understanding, what the above should do is fork a child process which will stop at exec and cause the parent-tracing process to exit wait(). The parent process should then have the child process continue execution normally by calling ptrace() with PT_CONTINUE. When I run the code, The child process is created, however, ptrace() with PT_CONTINUE seems to fail as the child process does not continue normal execution. ptrace's return value is 0 and errno is "Unknown error: 0". This email sent to thierry.bultel@atempo.com
This email sent to tlambert@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert