The reason is why the start-stop-daemon (--stop, --start and --status),
when using the --name atribute, search for a program who had the correct
PID file and the correct program name too. However, ddclient, when
running in deamon mode, changes its name each 10 seconds (it starts with
the name ddclient, then changes to "ddclient - sleeping [...] 300
seconds", etc ).

To correct this, I make a simple fix in the file
'ddclient-3.8.0/debian/ddclient.init' (obtained via apt-get source
command).

The patch file follows below. The patched file and the patch was
submitted as an attachment.

--- ddclient.init       2012-01-25 03:41:41.000000000 -0200
+++ ddclient.init.new   2014-06-10 21:39:40.526410491 -0300
@@ -51,10 +51,10 @@
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
-       start-stop-daemon --test --start --quiet \
-               --pidfile $PIDFILE --name $NAME --startas $DAEMON \
-               >/dev/null \
-               || return 1
+
+       # FIX The deamon name changes all the time when running in deamon mode.
+       # Using a alternative method to check if the program still running.
+       ( read pid < $PIDFILE && ps -p $pid ) >/dev/null 2>&1 && return 1

        start-stop-daemon --start --quiet \
                --pidfile $PIDFILE --name $NAME --startas $DAEMON \
@@ -76,8 +76,17 @@
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
+
+       # FIX The deamon name changes all the time when running in deamon mode.
+       # Using a alternative method to stop the program (check using ps and
+       # stop using only the --pidfile option - without --name).
+       ( read pid < "$PIDFILE" && ps -p "$pid" ) >/dev/null 2>&1 \
+               && start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
+               --pidfile $PIDFILE
+       # Now, we can run the original command to get the correct return value
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
                --pidfile $PIDFILE --name $NAME
+
        return "$?"
 }

** Patch added: "ddclient.init.patch"
   
https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/1241612/+attachment/4129371/+files/ddclient.init.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1241612

Title:
  'service ddclient stop' doesn't work

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/1241612/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to