X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mount-latest-subvol;h=d39b8823f89a1da652c035f320a513d1cf13dc45;hb=7a82762b44f4732f6b075a0cb5d8b258f5022d12;hp=b4bec8efe51c1aec7101d4aa78b84a219b8e1bec;hpb=718da868cfeee6a0e7b61ef2b95c83fe96178312;p=distro-setup diff --git a/mount-latest-subvol b/mount-latest-subvol index b4bec8e..d39b882 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -163,19 +163,22 @@ for vol in q a o i; do 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