"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
atexit: add Signalled() function - set if called from a signal #4804
Nick Craig-Wood83406bc4737b
diff --git a/lib/atexit/atexit.go b/lib/atexit/atexit.goindex d52d50371..d0c3b08ad 100644--- a/lib/atexit/atexit.go+++ b/lib/atexit/atexit.go@@ -8,6 +8,7 @@ import ("os""os/signal""sync"+ "sync/atomic""github.com/rclone/rclone/fs")@@ -18,6 +19,7 @@ var (exitChan chan os.SignalexitOnce sync.OnceregisterOnce sync.Once+ signalled int32)// FnHandle is the type of the handle returned by function `Register`@@ -40,6 +42,7 @@ func Register(fn func()) FnHandle {if sig == nil {return}+ atomic.StoreInt32(&signalled, 1)fs.Infof(nil, "Signal received: %s", sig)Run()fs.Infof(nil, "Exiting...")@@ -50,6 +53,11 @@ func Register(fn func()) FnHandle {return &fn}+// Signalled returns true if an exit signal has been received+func Signalled() bool {+ return atomic.LoadInt32(&signalled) != 0+}+// Unregister a function using the handle returned by `Register`func Unregister(handle FnHandle) {fnsMutex.Lock()