[Pkg-sysvinit-devel] Bug#390936: umountnfs.sh: fuser command called with incorrect parameters

Markus Schoder lists at gammarayburst.de
Tue Oct 3 20:29:46 UTC 2006


Package: initscripts
Version: 2.86.ds1-30

The line

fuser -k INT -m $DIRS

is syntactically not correct it probably should be:

fuser -k -INT -m $DIRS

and similarly for another line with TERM instead of INT.

I have a patch with some additional changes for the fuser usage
that seemed like a good idea to me:

1. Replace INT with TERM and TERM with KILL. SIGINT is really only
meant for interactive use and does not reliably terminate a process.
SIGKILL is the typical last resort solution since it cannot be
caught by the process.

2. Use return value of fuser instead of string comparison with fuser
output to check for not yet terminated processes.

3. Put sleep after loop condition to prevent delay in case no
processes are left immediately.

4. Use -s switch to prevent clutter.

--- umountnfs.sh.old    2006-09-29 19:12:09.000000000 +0200
+++ umountnfs.sh        2006-10-03 00:25:58.993986124 +0200
@@ -84,18 +84,17 @@
                # 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
+                       fuser -k -TERM -s -m $DIRS
                        [ "$VERBOSE" = no ] || log_action_end_msg 0

                        for count in 1 2 3 4 5; do # Wait up to 5 seconds
+                           fuser -s -m $DIRS || break
                            sleep 1
-                           [ -z "`fuser -m $DIRS 2> /dev/null`" ] && break
                        done

-                       pidsleft=`fuser -m $DIRS 2>/dev/null`
-                       if [ "$pidsleft" ] ; then
+                       if fuser -s -m $DIRS; then
                            [ "$VERBOSE" = no ] || log_action_begin_msg "Killing non-system processes"
-                           fuser -k TERM -m $DIRS
+                           fuser -k -KILL -s -m $DIRS
                            [ "$VERBOSE" = no ] || log_action_end_msg 0
                        fi
                else


--
Markus




More information about the Pkg-sysvinit-devel mailing list