From d8d067e3e2c6492fa16d6290e7b5fbb9a9e0b745 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Mon, 1 Dec 2008 13:57:33 -0500 Subject: __pids_var_run: Handle multi-line pid files correctly (#473287) We were only reading the first line of pid files. Given that even those first lines could have multiple pids, this *shouldn't* break anything, but there may be some scripts with multi-line pid files that aren't expecting this. --- rc.d/init.d/functions | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'rc.d') diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index acef3321..bb580486 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -152,10 +152,15 @@ __pids_var_run() { pid= if [ -f "$pid_file" ] ; then local line p - read line < "$pid_file" - for p in $line ; do - [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" - done + + while : ; do + read line + [ -z "$line" ] && break + for p in $line ; do + [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p" + done + done < "$pid_file" + if [ -n "$pid" ]; then return 0 fi -- cgit v1.2.1