Skip to main content

Killing How to kill all child processes of a terminal, not a tty session?

Source Link
iAdjunct
  • 1.7k
  • 1
  • 17
  • 24

Killing all child processes of a terminal, not a tty session

At my workplace, we have a high-performance computing-cluster managed by SLURM.

Some people's jobs spawn lots of processes with, as a federation, are one job. They also write the top-level controller poorly, so SIGINT causes the child processes to become zombies.

Because of the nature of this environment, it's not reasonable (for no actually valid reason) to expect them to fix this.

So I'm trying to make a submission wrapper which, at the end of the job, will kill all the child processes.

ps by default grabs all processes associated with the current tty session. However, SLURM does stupid stuff and ps isn't just the processes for THIS task of this job, but also OTHER tasks as well so it kills everything on a physical node whenever one job dies.

So, how do I get/kill all the jobs which are children of the current bash script?