]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
fix 12 year old bug in pidofproc
authorElan Ruusamäe <glen@delfi.ee>
Mon, 18 May 2015 13:22:14 +0000 (16:22 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Mon, 18 May 2015 13:22:14 +0000 (16:22 +0300)
fallback to pidof did not work, i.e the output was sent without
filtering via filter_chroot

maybe it's not neccessary at all then? :)

lib/functions

index d7d5e9d19f5de0e30d99d54c3ee2cec8b0709baa..5d6dfbdd61c6a627ea22d76c325d88d2cb757f35 100644 (file)
@@ -981,14 +981,17 @@ pidofproc() {
                *) pidfile="/var/run/$pidfile";;
        esac
        if [ -f "${pidfile}" ]; then
-               local p pid=""
+               local p
                for p in $(< "${pidfile}"); do
                        [ -z "$(echo "$p" | awk '{gsub(/[0-9]/,"");print;}')" ] && pid="$pid $p"
                done
        fi
 
-       # Next try "pidof"
-       [ -z "$pid" ] && pidof -o $$ -o $PPID -o %PPID -x "$1"
+       if [ -z "$pid" ]; then
+               # Next try "pidof"
+               pid=$(pidof -o $$ -o $PPID -o %PPID -x "$1")
+       fi
+
        pid=$(filter_chroot $pid)
        echo $pid
 }
This page took 0.170555 seconds and 4 git commands to generate.