on-internet
← Community

Tracing syscalls of a process and all forked processes

Stack Overflow ·

I'm using ptrace to trace the syscalls of a process. After forking the process, I use PTRACE_TRACEME to start trace the the process. The code looks like this: while (true) { int status; int gotPid; gotPid = waitpid(pid, &status, 0); if (WIFEXITED(status) || WIFSIGNALED(status)) { break; } if (WIFSTOPPED(status)) { handleTrace(); } } Then there is the handleTrace function, which looks like this. long syscall; syscall = ptrace(PTRACE_PEEKUSER, pid, 8 * ORIG_RAX, NULL); // do something with the syscall // continue program ptrace(PTRACE_SYSCALL, pid, NULL, NULL); This is all good, but if the progr

Comments

Sign in or sign up to comment and upvote.

No comments yet.