I'm looking for code examples on how to use the Linux system call ptrace()
to trace system calls of a process and all its child, grandchild, etc processes. Similar to the behaviour of strace
when it is fed the fork flag -f
.
I'm aware of the alternative of looking into the sources of strace but I'm asking for a clean tutorial first in the hopes of getting a more isolated explanation.
I'm gonna use this to implement a fast generic system call memoizer similar to https://github.com/nordlow/strace-memoize but written in a compiled language. My current code examples I want to extend with this logic is my fork of ministrace at https://github.com/nordlow/ministrace/blob/master/ministrace.c