From cf0d60f40c4c949fcf3acc52f2395b1737d750e1 Mon Sep 17 00:00:00 2001 From: Mikhail Kiselev Date: Tue, 10 Feb 2026 16:00:06 +0300 Subject: [PATCH] fix: improve app restart after update --- internal/services/updater/updater.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/services/updater/updater.go b/internal/services/updater/updater.go index 3e77db5..fb73dfa 100644 --- a/internal/services/updater/updater.go +++ b/internal/services/updater/updater.go @@ -187,12 +187,27 @@ func (u *Updater) DownloadAndInstall(progressCallback func(float64)) error { func (u *Updater) RestartApp() error { destPath := filepath.Join(InstallPath, AppName) - // Launch new app - cmd := exec.Command("open", destPath) + // Use shell to launch new app after this process exits + // The sleep ensures the current app has time to exit + script := fmt.Sprintf(`sleep 1 && open "%s"`, destPath) + cmd := exec.Command("sh", "-c", script) + cmd.Stdout = nil + cmd.Stderr = nil + cmd.Stdin = nil + + // Detach the process so it continues after we exit if err := cmd.Start(); err != nil { return fmt.Errorf("failed to launch updated app: %w", err) } + // Release the process so it doesn't become a zombie + go func() { + _ = cmd.Wait() + }() + + // Give the shell time to start + time.Sleep(100 * time.Millisecond) + // Exit current app os.Exit(0) return nil