Package: initscripts
Version: 2.88dsf-7
Severity: minor
Tags: patch

Please have a look at the attached diff.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages initscripts depends on:
ii  coreutils                     8.5-1      GNU core utilities
ii  debianutils                   3.2.3      Miscellaneous utilities specific t
ii  libc6                         2.10.2-9   Embedded GNU C Library: Shared lib
ii  lsb-base                      3.2-23.1   Linux Standard Base 3.2 init scrip
ii  mount                         2.17.2-2   Tools for mounting and manipulatin
ii  sysv-rc                       2.88dsf-7  System-V-like runlevel change mech
ii  sysvinit-utils                2.88dsf-7  System-V-like utilities

Versions of packages initscripts recommends:
ii  e2fsprogs                     1.41.12-1  ext2/ext3/ext4 file system utiliti
ii  psmisc                        22.11-1    utilities that use the proc file s

initscripts suggests no packages.

-- Configuration Files:
/etc/default/bootlogd changed [not included]
/etc/default/tmpfs changed [not included]
/etc/init.d/bootlogd changed [not included]
/etc/init.d/mountdevsubfs.sh changed [not included]

-- no debconf information


Cheers,

-- 
Cristian
--- debian/src/initscripts/etc/init.d/sendsigs.orig	2010-05-30 20:07:15.000000000 +0200
+++ debian/src/initscripts/etc/init.d/sendsigs	2010-05-30 20:14:36.000000000 +0200
@@ -1,24 +1,26 @@
-#! /bin/sh
+#!/bin/sh
 ### BEGIN INIT INFO
 # Provides:          sendsigs
-# Required-Start:    
+# Required-Start:
 # Required-Stop:     umountnfs
 # Default-Start:
 # Default-Stop:      0 6
 # Short-Description: Kill all remaining processes.
-# Description: 
+# Description:
 ### END INIT INFO
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
 . /lib/lsb/init-functions
 
+INITCTL=/sbin/initctl
+
 # Make it possible to see who the misbehaving processes are
 report_unkillable() {
-	if [ -x /usr/bin/pstree ] ; then
+	if [ -x /usr/bin/pstree ]; then
 		echo "Currently running processes (pstree):"
 		pstree
-	elif [ -x /bin/ps ] ; then
+	elif [ -x /bin/ps ]; then
 		echo "Currently running processes (ps):"
 		ps -ef
 	fi
@@ -27,36 +29,44 @@
 do_stop () {
 	OMITPIDS=
 
-	# The /var/run/sendsigs.omit file is used to be compatible
+	# The /var/run/sendsigs.omit file used to be compatible
 	# with Ubuntu.
 	for omitfile in /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
-		if [ -e $omitfile ]; then
+		# $omitfile may be a file, but is it readable?
+		if [ -r $omitfile ]; then
+			# FIXME: $omitfile may be readable, but contents may
+			#	 differ from what is expected.
 			for pid in $(cat $omitfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
 			done
 		fi
 	done
+	# at this point OMITPIDS may still be empty
 
 	# Load sendsigs.omit.d/packagename files too, to make it
 	# possible for scripts that need to modify the list of pids at
 	# run time without race conditions.
-	if [ -d /lib/init/rw/sendsigs.omit.d/ ]; then
+	if [ -d /lib/init/rw/sendsigs.omit.d ]; then
 		for pidfile in /lib/init/rw/sendsigs.omit.d/*; do
-			[ -f "$pidfile" ] || continue
+			[ -r "$pidfile" ] || continue
+			# FIXME: $pidfile may be readable, but contents may
+			#	 differ from what is expected.
 			for pid in $(cat $pidfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
 			done
 		done
 	fi
+	# at this point OMITPIDS may still be empty
 
 	# Upstart jobs have their own "stop on" clauses that sends
 	# SIGTERM/SIGKILL just like this, so if they're still running,
 	# they're supposed to be
-	if [ -x /sbin/initctl ]; then
-		for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do
+	if [ -x $INITCTL ]; then
+		for pid in $($INITCTL list | sed -ne "/process [0-9]/s/.*process //p"); do
 			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
 		done
 	fi
+	# at this point OMITPIDS may still be empty
 
 	# Flush the kernel I/O buffer before we start to kill
 	# processes, to make sure the IO of already stopped services to
@@ -67,60 +77,67 @@
 
 	# Kill all processes.
 	log_action_begin_msg "Asking all remaining processes to terminate"
+	# FIXME: at this point OMITPIDS may be empty
 	killall5 -15 $OMITPIDS # SIGTERM
 	log_action_end_msg 0
-	alldead=""
-	for seq in 1 2 3 4 5 6 7 8 9 10; do
+	alldead=
+	seq=0
+	max_seq=10
+	while [ $seq -lt $max_seq ]; do
 		# use SIGCONT/signal 18 to check if there are
 		# processes left.  No need to check the exit code
-		# value, because either killall5 work and it make
-		# sense to wait for processes to die, or it fail and
+		# value, because either killall5 works and it makes
+		# sense to wait for processes to die, or it fails and
 		# there is nothing to wait for.
 
 		# did an upstart job start since we last polled initctl? check
 		# again on each loop and add any new jobs (e.g., plymouth) to
 		# the list.  If we did miss one starting up, this beats waiting
-		# 10 seconds before shutting down.
-		if [ -x /sbin/initctl ]; then
-		    for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do
-			OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
-		    done
+		# $max_seq seconds before shutting down.
+		if [ -x $INITCTL ]; then
+			for pid in $($INITCTL list | sed -ne "/process [0-9]/s/.*process //p"); do
+				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+			done
 		fi
-		if killall5 -18 $OMITPIDS ; then
-		    :
+
+		# FIXME: at this point OMITPIDS may be empty
+		if killall5 -18 $OMITPIDS; then
+			:
 		else
-		    alldead=1
-		    break
+			alldead=1
+			break
 		fi
 
 		sleep 1
+		seq=$(($seq + 1))
 	done
-	if [ -z "$alldead" ] ; then
-	    report_unkillable
-	    log_action_begin_msg "Killing all remaining processes"
-	    killall5 -9 $OMITPIDS # SIGKILL
-	    log_action_end_msg 1
+	if [ "$alldead" ]; then
+		log_action_begin_msg "All processes ended within $seq seconds."
+		log_action_end_msg 0
 	else
-	    log_action_begin_msg "All processes ended within $seq seconds."
-	    log_action_end_msg 0
+		report_unkillable
+		log_action_begin_msg "Killing all remaining processes"
+		# FIXME: at this point OMITPIDS may be empty
+		killall5 -9 $OMITPIDS # SIGKILL
+		log_action_end_msg 1
 	fi
 }
 
-case "$1" in
-  start)
-	# No-op
-	;;
-  restart|reload|force-reload)
-	echo "Error: argument '$1' not supported" >&2
-	exit 3
-	;;
-  stop)
-	do_stop
-	;;
-  *)
-	echo "Usage: $0 start|stop" >&2
-	exit 3
-	;;
+case $1 in
+	start)
+		# No-op
+		;;
+	restart|reload|force-reload)
+		echo "Error: argument '$1' not supported" >&2
+		exit 3
+		;;
+	stop)
+		do_stop
+		;;
+	*)
+		echo "Usage: $0 start|stop" >&2
+		exit 3
+		;;
 esac
 
 :

Reply via email to