Sergei Golubchik <sergii@pisem.net> writes:
On Dec 29, Hakan Kuecuekyilmaz wrote:
+# Note: Do not run this script with root privileges. +# We use killall -9, which can cause severe side effects!
You can use
killall -u `whoami`
not perfect, but still much safer.
There is another, robust way to do this: Make the parent process a group leader with setpgid(0,0). Then `kill -9 -$$` will kill only the processes started from that parent (or from children, recursively). Or use setsid to create a session leader for even more robust killing (there is a setsid command available to do this within shell scripts). (You might not need this for your purpose, but I thought I would mention it in case you at some point may want to run this in Buildbot or similar). - Kristian.