Package: watchdog
Version: 5.15-2
Severity: normal
Tags: patch
Usertags: origin-ubuntu bionic ubuntu-patch

Dear Maintainer,

On Ubuntu 14.04, it was noticed that "sudo service watchdog start"              
command was sometimes hanging indefinitely. Investigation revealed              
that the watchdog init script tries sending a SIGTERM to the process            
present in the pidfile for the wd_keepalive daemon. However, the                
init script does not seem to clear pidfiles while stopping services,            
so the pidfile is often stale. This resulted in SIGTERM being sent              
not to wd_keepalive, but to a service which was not responding to               
SIGTERM, causing the command mentioned to hang.                                 
This issue seems to be present even on the latest version of the                
watchdog package.                                                               
The issue was worked around by explicitly specifiying the name                  
of the executable to stop in "start-stop-daemon --stop". The man                
page for start-stop-daemon explicitly mentions that not doing                   
so while supplying a pidfile can cause unintended processes to                  
be acted upon.                                                                  
This issue probably only reproduces on systems where the watchdog               
service is stopped and restarted, which might not be very common.

*** /tmp/tmpYBTSCa/bug_body

In Ubuntu, the attached patch was applied to fix the issue.

  [ Arijit Banerjee ]
  * Fix bug where SIGTERM is sent to stale pid (LP: #1750942)

Thanks for considering the patch. Apologies for any inaccuracies
while reporting this, it's my first patch to Debian.

-- System Information:
Debian Release: jessie/sid
  APT prefers trusty-updates
  APT policy: (500, 'trusty-updates'), (500, 'trusty')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.13.0-52-generic (SMP w/3 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -u watchdog-5.15/debian/changelog watchdog-5.15/debian/changelog
only in patch2:
--- watchdog-5.15.orig/debian/init
+++ watchdog-5.15/debian/init
@@ -54,7 +54,7 @@
 	# make sure that wd_keepalive is stopped
 	log_begin_msg "Stopping watchdog keepalive daemon..."
         start-stop-daemon --stop --quiet --oknodo --retry $STOP_RETRY_SCHEDULE \
-            --pidfile /var/run/$
+            --pidfile /var/run/$ --exec $KEEPALIVE_DAEMON
         log_end_msg $?
 	# also remove the sendsigs omit file
@@ -74,7 +74,7 @@
 	log_begin_msg "Stopping watchdog daemon..."
 	start-stop-daemon --stop --quiet --retry $STOP_RETRY_SCHEDULE \
-	    --pidfile /var/run/$
+	    --pidfile /var/run/$ --exec $DAEMON
 	log_end_msg $?
 	if [ $run_wd_keepalive = 1 ]
@@ -99,7 +99,7 @@
     log_daemon_msg "Restarting $NAME"
     log_progress_msg "Stopping $NAME daemon..."
     start-stop-daemon --stop --pidfile /var/run/$ --quiet \
-	--retry $STOP_RETRY_SCHEDULE || log_end_msg $?
+	--retry $STOP_RETRY_SCHEDULE --exec $DAEMON || log_end_msg $?
     log_progress_msg "Starting $NAME daemon..."
     start-stop-daemon --start --quiet --pidfile /var/run/$ \
 	--exec $DAEMON -- $watchdog_options

Reply via email to