From 81d4666525ab70c2f28ac9295fb4af9bfb69aa07 Mon Sep 17 00:00:00 2001 From: GaugeK Date: Tue, 25 Aug 2020 12:45:18 +1000 Subject: [PATCH] Make sure not to do an infinite loop --- fet.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fet.sh b/fet.sh index 004c26f..382bfb5 100755 --- a/fet.sh +++ b/fet.sh @@ -36,8 +36,13 @@ if [ -e /proc/$$/comm ]; then eq "$line" "PPid*" && ppid=${line##*:?} && break done < "/proc/${ppid:-$PPID}/status" + # Make sure not to do an infinite loop + [ "$pppid" = "$ppid" ] && break + pppid="$ppid" + # get name of binary read -r name < "/proc/$ppid/comm" + case $name in *sh|"${0##*/}") ;; # skip shells *[Ll]ogin*|*init*) break;; # exit when the top is reached