tracking all child process spawned by a root process
<p>I'm inspecting a certain make system that runs compilers. I want to track all child processes ever spawned by such a "root" process.</p>

<p>I'm aware there's the <code>ps</code> command and as I'm a Python user, the <code>psutil</code> package. But I'm not sure if I'll miss some short lived processes between the calls.</p>

<p>I think what I really want is something like <code>inotify</code> (or <code>watchdog</code> in Python), but instead of tracking directory, it tracks all child process activity.</p>

<p>Is there such a system call, or preferably, package of Python, that does this?</p>

<p>Thanks in advance.</p>

<p><code>sttace</code> can provide that info. But you may have to parse the output to get just the info you are interested in.</p>

<pre><code>strace -f -e trace=process &lt;executable&gt;
</code></pre>

<p>That will trace all child processes of <code>&lt;executable&gt;</code> and will trace only the process related syscalls (essentially <code>wait</code>, <code>fork</code>, <code>clone</code> and <code>exec</code>).</p>

python linux process