collectd: sqm_collect: optimise parent search
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Sun, 3 Oct 2021 10:23:36 +0000 (11:23 +0100)
committerKevin Darbyshire-Bryant <6500011+ldir-EDB0@users.noreply.github.com>
Wed, 6 Oct 2021 11:13:11 +0000 (12:13 +0100)
There can be only 1 parent process ID, so as soon as we find it, print
it and exit - there's no point searching any of the following lines

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
utils/collectd/files/exec-scripts/sqm_collectd.sh

index 690837017ed12c7a1ec2ab2c5c8f57e3b4b80b6a..07fe555151440fe12b32c0e6bd5c9b278d3022df 100755 (executable)
@@ -100,7 +100,7 @@ process_qdisc() {
 }
 
 # while not orphaned
-while [ $(awk '$1 ~ "^PPid:" {print $2}' /proc/$$/status) -ne 1 ] ; do
+while [ $(awk '$1 ~ "^PPid:" {print $2;exit}' /proc/$$/status) -ne 1 ] ; do
        for ifc in "$@" ; do
                process_qdisc "$ifc"
        done