Make fuser command time out

This avoids situations in which fuser hangs because of open files on
remote file systems when the remote system goes down.
I have also passed this bug on to the maintainers of psmisc since it
should really be fixed in fuser.
This is based on a patch submitted by evermind@tuxfamily.org

Reported-by: evermind@tuxfamily.org
X-Gentoo-Bug: 455458
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=455458
This commit is contained in:
William Hubbs 2013-02-16 12:53:31 -06:00
parent 274d6eee66
commit 6794441224
2 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,10 @@
# consolefont, numlock, etc ...)
rc_tty_number=12
# This is how long fuser should wait for a remote server to respond. The
# default is 60 seconds, but it can be adjusted here.
#rc_fuser_timeout=60
##############################################################################
# CGROUPS RESOURCE MANAGEMENT

View File

@ -41,7 +41,8 @@ do_unmount()
retry=4 # Effectively TERM, sleep 1, TERM, sleep 1, KILL, sleep 1
while ! LC_ALL=C $cmd "$mnt" 2>/dev/null; do
if type fuser >/dev/null 2>&1; then
pids="$(fuser $f_opts "$mnt" 2>/dev/null)"
pids="$(timeout -k 10 -s KILL "${rc_fuser_timeout:-60}" \
fuser $f_opts "$mnt" 2>/dev/null)"
fi
case " $pids " in
*" $$ "*)