I'm trying to build a process container. The container will trigger other programs. For example - a bash script that launches running background tasks with '&' usage.
The important feature I'm after is this: when I kill the container, everything that has been spawned under it should be killed. Not just direct children, but their descendants too.
When I started this project, I mistakenly believed that when you killed a process its children were automatically killed too. I've sought advice from people who had the same incorrect idea. While it's possible to catch a signal and pass the kill on to children, that's not what I'm looking for here.
I believe what I want to be achievable, because when you close an xterm, anything that was running within it is killed unless it was nohup'd. This includes orphaned processes. That's what I'm looking to recreate.
I have an idea that what I'm loooking for involves unix sessions.
If there was a reliable way to identify all the descendants of a process, it would be useful to be able to send them arbitrary signals, too. e.g. SIGUSR1.
SIGHUP
to it's direct children processes. The default handler of hang up signal aborts process execution, so the default route is to kill all the descendants. Read more on processes and process groups. – alex Jun 11 '11 at 13:27