Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

cmount: don't call host.Umount if a signal has been received

Nick Craig-Woodf7d9b157079b
diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go
index 38503d8ae..07a45daab 100644
--- a/cmd/cmount/mount.go
+++ b/cmd/cmount/mount.go
@@ -19,6 +19,7 @@ import (
"github.com/pkg/errors"
"github.com/rclone/rclone/cmd/mountlib"
"github.com/rclone/rclone/fs"
+ "github.com/rclone/rclone/lib/atexit"
"github.com/rclone/rclone/vfs"
)
@@ -187,9 +188,17 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (<-chan error
unmount := func() error {
// Shutdown the VFS
fsys.VFS.Shutdown()
- fs.Debugf(nil, "Calling host.Unmount")
- if host.Unmount() {
- fs.Debugf(nil, "host.Unmount succeeded")
+ var umountOK bool
+ if atexit.Signalled() {
+ // If we have received a signal then FUSE will be shutting down already
+ fs.Debugf(nil, "Not calling host.Unmount as signal received")
+ umountOK = true
+ } else {
+ fs.Debugf(nil, "Calling host.Unmount")
+ umountOK = host.Unmount()
+ }
+ if umountOK {
+ fs.Debugf(nil, "Unmounted successfully")
if runtime.GOOS == "windows" {
if !waitFor(func() bool {
_, err := os.Stat(mountpoint)