As of now, despite of being stated that -D option runs strace as a "detached"
grandchild (and the option name being named after "daemon"), strace
still runs in the same process group and session, thus not being
"detached" in a common sense and being subjected to process group kill
and session termination kill. Quoting[1]:
I stumble upon unexpected behavior: if strace is used with option '-D'
(tracer as a detached grandchild) and process (leader) kills whole
process group, it will kill strace too.
It can be easily reproduced by `timeout` from "coreutils":
Here is "strace log" of `strace` inside `timeout`:
strace: Process 30603 attached
wait4(-1, <unfinished ...>) = ?
+++ killed by SIGKILL +++
I think that detached `strace` should not be killed like that -- it
should not be part of former grandparents' "job pipeline".
While this behaviour is not exactly intuitive, it is implemented this
way for quite some time, so it might be relied upon by some of strace
users. In order to address this issue, two new levels of
"daemonisation" are added, that put strace in a separate process group
and session, respectively.