From 5f791079fc3325d156377c83abdde65cecf61721 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 11 Apr 2026 13:20:10 +0100 Subject: [PATCH] gui: join Wait goroutines on shutdown --- cmd/gui/gui.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/gui/gui.go b/cmd/gui/gui.go index fbe03bc38..227d66ec5 100644 --- a/cmd/gui/gui.go +++ b/cmd/gui/gui.go @@ -11,6 +11,7 @@ import ( "net/url" "os" "strings" + "sync" "github.com/rclone/rclone/cmd" "github.com/rclone/rclone/fs" @@ -201,14 +202,18 @@ Use --no-auth to disable authentication entirely: } } - // Wait for either server to exit, then shut both down + // Wait for either server to exit, then shut both down and + // join the second goroutine before returning. defer systemd.Notify()() + var wg sync.WaitGroup done := make(chan struct{}, 2) - go func() { rcServer.Wait(); done <- struct{}{} }() - go func() { guiServer.Wait(); done <- struct{}{} }() + wg.Add(2) + go func() { defer wg.Done(); rcServer.Wait(); done <- struct{}{} }() + go func() { defer wg.Done(); guiServer.Wait(); done <- struct{}{} }() <-done _ = rcServer.Shutdown() _ = guiServer.Shutdown() + wg.Wait() return nil }, }