Bug 473287 - killproc doesn't kill all processes found in pidfile
killproc doesn't kill all processes found in pidfile
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-27 09:25 EST by Ruben Kerkhof
Modified: 2014-03-16 23:16 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-12-01 14:04:06 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch, avoiding bugzilla pasting fun (616 bytes, text/plain)
2008-12-01 12:13 EST, Bill Nottingham
no flags Details

  None (edit)
Description Ruben Kerkhof 2008-11-27 09:25:56 EST
Description of problem:

Some programs (HAProxy for example when running with nprocs=2) write multiple pids to the same pidfile, each on its own line. Killproc only reads the first line of a pid file, so it will only kill the first process found.
Comment 1 Bill Nottingham 2008-12-01 12:07:10 EST
Hm, this would be a behavior change - this may have unintended consequences.

diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index acef332..bb58048 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

Does this fix it for you?
Comment 2 Bill Nottingham 2008-12-01 12:13:54 EST
Created attachment 325267 [details]
patch, avoiding bugzilla pasting fun
Comment 3 Ruben Kerkhof 2008-12-01 13:48:36 EST
This fixes it for me, thanks. I'm not sure what other programs will break though...
Comment 4 Bill Nottingham 2008-12-01 14:04:06 EST
http://git.fedorahosted.org/git/?p=initscripts.git;a=commitdiff;h=d8d067e3e2c6492fa16d6290e7b5fbb9a9e0b745

Will be in rawhide with the next build. Due to the behavior change, it's very unlikely to be backported to a release.

Note You need to log in before you can comment on or make changes to this bug.