Hi,

The following patch fixes the init script start/restart return code. The
problem is that pidofproc tries to read from the same file where it is
redirected, causing it to fail.

Best regards,

V.
>From a581628c059ac097e837c23aa2fd16e70e8ca7bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= <vincent.ste...@laposte.net>
Date: Tue, 5 Jun 2012 23:02:26 +0200
Subject: [PATCH] Fix return code for start and restart
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix start/restart init script return codes. Avoid that pidofproc reads from the
same file where it is redirected.

Signed-off-by: Vincent Stehlé <vincent.ste...@laposte.net>
---
 debian/irqbalance.init |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/debian/irqbalance.init b/debian/irqbalance.init
index 4fd8c08..791b783 100644
--- a/debian/irqbalance.init
+++ b/debian/irqbalance.init
@@ -10,9 +10,9 @@
 # irqbalance init script
 # August 2003
 # Eric Dorland
- 
+
 # Based on spamassassin init script
- 
+
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/irqbalance
 NAME=irqbalance
@@ -32,7 +32,7 @@ test -x $DAEMON || exit 0
 . /lib/lsb/init-functions
 
 test -f /etc/default/irqbalance && . /etc/default/irqbalance
-             
+
 test "$ENABLED" != "0" || exit 0
 
 if test "$ONESHOT" != "0"; then
@@ -51,16 +51,16 @@ case "$1" in
         fi
 
         start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS $DOPTIONS
-        pidofproc $PNAME > $PIDFILE
+        pidofproc -p "$PIDFILE" "$PNAME" >/dev/null || rm -f "$PIDFILE"
 
         log_end_msg $?
         ;;
     stop)
         log_begin_msg "Stopping $DESC: $NAME"
-        
+
         start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
         rm -f $PIDFILE
-        
+
         log_end_msg $?
         ;;
     restart|force-reload)
@@ -70,7 +70,7 @@ case "$1" in
         rm -f $PIDFILE
 
         start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS $DOPTIONS
-        pidofproc $PNAME > $PIDFILE
+        pidofproc -p "$PIDFILE" "$PNAME" >/dev/null || rm -f "$PIDFILE"
 
         log_end_msg $?
         ;;
-- 
1.7.10

Reply via email to