Bug#258420: [Pkg-sysvinit-devel] Bug#258420: initscripts: On shutdown, first kills all processes including portmap, then tries to unmount network filesystems (which fails)

Petter Reinholdtsen pere at hungry.com
Fri Sep 8 12:30:45 UTC 2006


tags 258420 + patch
thanks

[Petter Reinholdtsen]
> Another idea is to "split" sendsigs into two scripts, one sendsigs-nfs
> to kill all processes currently using the NFS-mounted volumes, for
> example using 'fuser -m /path/to/nfs-volume'

An even better idea is to add code into umountnfs.sh to kill the
processes using the mount points that are about to be umounted.

Here is a patch to implement that idea.  It is untested.  I'm not sure
if we should depend on psmisc for fuser, thus making it an essential
package, or only enable it if it is present as this patch is doing.

Index: debian/initscripts/postinst
===================================================================
--- debian/initscripts/postinst	(revisjon 856)
+++ debian/initscripts/postinst	(arbeidskopi)
@@ -92,6 +92,12 @@
 	update-rc.d -f hostname.sh remove >/dev/null 2>&1 || :
 fi
 
+# In 2.86.ds1-18, the sendsigs script were moved.
+if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-18"
+then
+	update-rc.d -f sendsigs remove >/dev/null 2>&1 || :
+fi
+
 #
 # Okay, we could do this with update-rc.d, but that would probably
 # be pretty slow. This way we win some speed.
@@ -117,8 +123,8 @@
 #
 # Links in runlevels other than S
 #
-updatercd sendsigs               start 20 0 6 .
 updatercd umountnfs.sh           start 31 0 6 .
+updatercd sendsigs               start 37 0 6 .
 updatercd umountfs               start 40 0 6 .
 updatercd umountroot             start 60 0 6 .
 updatercd halt                   start 90 0 .
Index: debian/initscripts/etc/init.d/umountnfs.sh
===================================================================
--- debian/initscripts/etc/init.d/umountnfs.sh	(revisjon 856)
+++ debian/initscripts/etc/init.d/umountnfs.sh	(arbeidskopi)
@@ -36,8 +36,6 @@
 	# Remove bootclean flag files (precaution against symlink attacks)
 	rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
 
-	[ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems"
-
 	#
 	# Make list of points to unmount in reverse order of their creation
 	#
@@ -71,11 +69,22 @@
 
 	if [ "$DIRS" ]
 	then
+		# Kill all processes using the directories we try to umount
+		if [ -x /bin/fuser ] ; then
+			[ "$VERBOSE" = no ] || log_action_begin_msg "Asking non-system processes to terminate"
+			fuser -k INT -m $DIRS
+			[ "$VERBOSE" = no ] || log_action_end_msg 0
+			sleep 5
+			[ "$VERBOSE" = no ] || log_action_begin_msg "Killing non-system processes"
+			fuser -k TERM -m $DIRS
+			[ "$VERBOSE" = no ] || log_action_end_msg 0
+		fi
+
+		[ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems"
 		umount $FLAGS $DIRS
+		[ "$VERBOSE" = no ] || log_action_end_msg $?
 	fi
-	ES=$?
 
-	[ "$VERBOSE" = no ] || log_action_end_msg $ES
 }
 
 case "$1" in




More information about the Pkg-sysvinit-devel mailing list