[projects/rc-scripts] fix 12 year old bug in pidofproc

glen glen at pld-linux.org
Mon May 18 15:23:36 CEST 2015


commit 597298b301e3d050869596d81b06305e08e6eca5
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Mon May 18 16:22:14 2015 +0300

    fix 12 year old bug in pidofproc
    
    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 | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/lib/functions b/lib/functions
index d7d5e9d..5d6dfbd 100644
--- a/lib/functions
+++ b/lib/functions
@@ -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
 }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/rc-scripts.git/commitdiff/597298b301e3d050869596d81b06305e08e6eca5



More information about the pld-cvs-commit mailing list