if e umount -R $dir; then
unmounted+=($dir)
else
- echo "$0: failed to umount $dir"
- # lsof will fail if it finds no pids
- if ! e timeout 4 lsof $dir; then
- umount_ret=false
- ret=1
- continue
+ if pids=$(timeout 4 lsof -t $dir); then
+ timeout 4 lsof -w $dir
+ kill $pids
fi
- pids=$(lsof -t $dir) ||:
- kill $pids
+
+ # fuser will find open sockets that lsof won't, for example from gpg-agent.
+ # note: -v shows kernel processes, which then doesn't return true when we want
+ if timeout 4 fuser -m $dir &>/dev/null; then
+ fuser -TERM -mvk $dir
+ fi
+
sleep .5
if e umount -R $dir; then
unmounted+=($dir)
else
+ echo "$0: failed to umount $dir"
umount_ret=false
ret=1
continue