mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
mount: ensure atexit gets run on interrupt
When running `rclone mount`, there were 2 signal handlers for `os.Interrupt`. Those handlers would run concurrently and in some cases cause either unmount or `atexit.Run()` being skipped. In addition `atexit.Run()` will get called in `resolveExitCode` to ensure cleanup on errors.
This commit is contained in:
committed by
Nick Craig-Wood
parent
cdde8fa75a
commit
d022c81d99
@@ -13,6 +13,7 @@ import (
|
||||
fusefs "bazil.org/fuse/fs"
|
||||
"github.com/ncw/rclone/cmd/mountlib"
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/lib/atexit"
|
||||
"github.com/ncw/rclone/vfs"
|
||||
"github.com/ncw/rclone/vfs/vfsflags"
|
||||
"github.com/okzk/sdnotify"
|
||||
@@ -133,6 +134,7 @@ func Mount(f fs.Fs, mountpoint string) error {
|
||||
signal.Notify(sigInt, syscall.SIGINT, syscall.SIGTERM)
|
||||
sigHup := make(chan os.Signal, 1)
|
||||
signal.Notify(sigHup, syscall.SIGHUP)
|
||||
atexit.IgnoreSignals()
|
||||
|
||||
if err := sdnotify.SdNotifyReady(); err != nil && err != sdnotify.SdNotifyNoSocket {
|
||||
return errors.Wrap(err, "failed to notify systemd")
|
||||
|
||||
Reference in New Issue
Block a user