I want to spawn child processes inside child processes, and make it so, that if a parent is terminated, then each of its children is terminated recursively.
I'm currently using Python as the programming language, but I'm looking for a programming language agnostic solution.
What confuses me is that every
Process is configured as either "daemonic" or "non-daemonic", depending on the
daemon argument of
__init__(), which controls whether the child process is terminated or not, when the parent exits.
But, as the following documentation shows, if a
Process is "daemonic", then it cannot create children processes, and so it's impossible to achive what I want, i.e. to terminate children recursively, when a parent exits?
daemon The process’s daemon flag, a Boolean value. This must be set before start() is called. The initial value is inherited from the creating process. When a process exits, it attempts to terminate all of its daemonic child processes. Note that a daemonic process is not allowed to create child processes. Otherwise a daemonic process would leave its children orphaned if it gets terminated when its parent process exits. Additionally, these are not Unix daemons or services, they are normal processes that will be terminated (and not joined) if non-daemonic processes have exited.