I'm writing a bash script that kills a bunch of processes selected by certain criteria and then quits. The only problem is that those criteria apply to the script and its parent processes (
sshd) itself, so in order to avoid killing the script before it has done its work, I first get the matching processes with
ps, then filter out the script and its parents with
sed and finally kill the remaining processes with
Now I'm wondering whether I could simplify this to a single
pkill call, but obviously that can only work if
pkill is guaranteed to kill itself and its parent processes last if they occur in the list of processes to kill.
Is there such a guarantee implemented into