diff --git a/netfs b/netfs index ea7e4eb..020bf0a 100755 --- a/netfs +++ b/netfs @@ -4,6 +4,34 @@ . /etc/rc.conf . /etc/rc.d/functions +umount_all_netfs() { + local timeout=60 success=0 + local pids=() + + umount -a -O _netdev & + pids+=($!) + + umount -a -t "$NETFS" & + pids+=($!) + + while (( timeout-- )); do + [[ ! ( -d /proc/${pids[0]} && -d /proc/${pids[1]} ) ]] && return 0 + sleep 1 + done + + # failure -- send SIGTERM to hanging processes (hoping they respond) and + # lazy/force umount. + kill -15 $netdevpid $netfspid 2>/dev/null + + umount -lfa -O _netdev + (( success += $? )) + + umount -lfa -t "$NETFS" + (( success += $? )) + + return $(( !! success )) +} + case "$1" in start) stat_busy "Mounting Network Filesystems" @@ -16,10 +44,7 @@ case "$1" in ;; stop) stat_busy "Unmounting Network Filesystems" - umount -a -O _netdev - rc=$? - umount -a -t "$NETFS" - (( rc || $? )) && stat_die + umount_all_netfs || stat_die rm_daemon netfs stat_done ;;