From 213d1d303977b522de65f858876db0e8811498a4 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Wed, 22 Apr 2026 01:42:37 -0400 Subject: [PATCH] fix: truly detach Windows update batch via spawn+unref instead of exec Co-Authored-By: Claude Sonnet 4.6 --- src/native/updater.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/native/updater.ts b/src/native/updater.ts index d114f3c..1ad838b 100644 --- a/src/native/updater.ts +++ b/src/native/updater.ts @@ -1,5 +1,5 @@ import { Notification, app, ipcMain } from "electron"; -import { exec } from "child_process"; +import { exec, spawn } from "child_process"; import { createWriteStream, mkdirSync, writeFileSync } from "fs"; import { dirname, join } from "path"; import { tmpdir } from "os"; @@ -118,8 +118,13 @@ async function downloadAndInstall(url: string, version: string) { ].join("\r\n"); writeFileSync(batchPath, bat); - // Launch batch detached so it outlives this process - exec(`cmd /C start /B "" "${batchPath}"`); + // Spawn batch truly detached so it outlives this process + const child = spawn("cmd.exe", ["/C", batchPath], { + detached: true, + stdio: "ignore", + windowsHide: false, + }); + child.unref(); setUpdateReady(version); // restart button will just app.exit(0) — batch relaunches } else { await new Promise((resolve, reject) => {