Skip to content

Instantly share code, notes, and snippets.

@pasko
pasko / strace_parent.c
Created June 29, 2021 00:06
Demonstrate on-demand ptrace() of a single thread.
// Demonstrate on-demand ptrace() of a single thread, not affecting any other
// thread in the process. The Linux/x86-64 version.
//
// This differs from ptrace() examples I could find on the Web by:
// * Tracing the parent process from the child (same as Crashpad)
// * Allowing to run threads in the background
//
// This is just a *demo*. A lot of error situations are not checked for, same
// for process states (wrt to signals, for example). Uses the mix of
// fork(2)+threads and malloc() in the forked process. Uses pipe() for message