When debugging I often use killall
to kill a process. This is really a bad habit because there might be more processes running of the same name on the system.
Normally the process I want to kill is a descendant from the same parent (or grandparent) as killall
is started from. Often I want to kill a program started in the same terminal or a terminal in another tab (in Konsole).
Is there a way to tell killall
(or another killer) to limit the scope to processes started from this terminal or processes that are descendants from the same (grand)parent?
Best Answer
If you want to kill all processes from this session (processes which have the current tty as their controlling terminal):
Or even simpler:
According to pkill(1):
Both the
-t
and the-s
options could be combined (ANDed) with a pattern and other options, eg.pgrep -s0 -x foo
for the processes from this session named exactlyfoo
. Unfortunately, neitherpgrep
norpkill
support complex,tcpdump
-style predicates.