How to kill all subprocesses of shell?
Posted
by depesz
on Stack Overflow
See other posts from Stack Overflow
or by depesz
Published on 2010-04-11T19:34:23Z
Indexed on
2010/04/11
19:43 UTC
Read the original article
Hit count: 262
I'm writing bash script, which does several thing.
In the beginning it starts several monitor scripts, each of them runs some other tools.
At the end of my main script, I would like to kill all things that spawned from my shell.
So, it might looks like this:
#!/bin/bash
some_monitor1.sh &
some_monitor2.sh &
some_monitor3.sh &
do_some_work
...
kill_subprocesses
The thing is that most of these monitors spawn their own subprocesses, so doing (for example): killall some_monitor1.sh
will not always help.
Any other way to handle this situation?
© Stack Overflow or respective owner