'service ddclient stop' doesn't work

Bug #1241612 reported by qji
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
ddclient (Debian)
Fix Released
Unknown
ddclient (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Environment:
Ubuntu 12.04 64bit
ddclient version: 3.8.0-11.4ubuntu1

'service ddclient stop' command doesn't stop the ddclient daemon, and then the 'service ddclient start' doesn't realize the ddclient is already started, so it starts a new one. If you try many stop/start it will make many ddclient processes.

In the /etc/init.d/ddclient script the stop part tries this:
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
                --pidfile $PIDFILE --name $NAME

I tried the same in command line (without --quiet):

# start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile /var/run/ddclient.pid --name ddclient
No ddclient found running; none killed.

And it didn't stop the ddclient

But it works without the --name option:

# start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile /var/run/ddclient.pid

No output, but ddclient is stopped.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ddclient (Ubuntu):
status: New → Confirmed
Revision history for this message
Rarylson Freitas (rarylson) wrote :

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 "$?"
 }

Changed in ddclient (Ubuntu):
status: Confirmed → Fix Committed
status: Fix Committed → Confirmed
Revision history for this message
Rarylson Freitas (rarylson) wrote :

Now, the entire file...

Changed in ddclient (Ubuntu):
status: Confirmed → In Progress
Changed in ddclient (Ubuntu):
status: In Progress → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Rarylson Freitas (rarylson) wrote :

I'm not a frequent commiter in Ubuntu Launchpad. So, I don't know if I must mark this BUG as 'In Progress' or as 'Fix Commited'.

As my patch was not checked by the Ubuntu ddclient Team, some other improvements may be necessary in the patch, and I have no permition to commit to the Ubuntu branch (https://code.launchpad.net/~ubuntu-branches/ubuntu/precise/ddclient/precise), all I can do is mark this bug as 'In Progress' and wait for someone merge them to the upstream and/or related branches.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "ddclient.init.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in ddclient (Ubuntu):
status: In Progress → Confirmed
Revision history for this message
Rarylson Freitas (rarylson) wrote :

A similar patch was applyed in the package 3.8.1-1ubuntu2, as showed in: https://bugs.launchpad.net/ubuntu/+source/ddclient/+bug/980409

However, the last version in Ubuntu 12.04 LTS is 3.8.0-11.4ubuntu1. It is, the patch was not applyed to all Ubuntu versions.

Maybe the correct solution is apply the same patch in Ubuntu 12.04.

Revision history for this message
Richard Hansen (rhansen) wrote :

Fixed in ddclient 3.8.1-1.1.

Changed in ddclient (Ubuntu):
status: Confirmed → Fix Released
Changed in ddclient (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.