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

lib/atexit: fix occasional failure to unmount with CTRL-C #4957

Nick Craig-Wood8d847a4e9427
diff --git a/lib/atexit/atexit.go b/lib/atexit/atexit.go
index d0c3b08ad..575fbeb8b 100644
--- a/lib/atexit/atexit.go
+++ b/lib/atexit/atexit.go
@@ -77,9 +77,10 @@ func IgnoreSignals() {
// Run all the at exit functions if they haven't been run already
func Run() {
+ // Take the lock here so we wait until all have run before returning
+ fnsMutex.Lock()
+ defer fnsMutex.Unlock()
exitOnce.Do(func() {
- fnsMutex.Lock()
- defer fnsMutex.Unlock()
for fnHandle := range fns {
(*fnHandle)()
}