fix(desktop): correctly handle EPERM in updater shutdown checks

isProcessAlive treated every kill error as not alive, so EPERM
(process exists but no permission) was misclassified as exited.
This made shutdown evidence report backendExited and watchdogExited
true while the PID was still alive, allowing stopForUpdate to
succeed prematurely and risk installer launch while the backend
still held the loopback listener.

Distinguish EPERM (alive) from ESRCH (not alive) in both
backend-manager.ts and backend-watchdog.ts, matching Node.js
process.kill semantics.

Signed-off-by: lorenzozanee <wyz0707@proton.me>
This commit is contained in:
lorenzozanee committed 2026-08-31 11:05:28 +08:00
1 parent 899d3c7536
commit 75bdf0c390
2 files changed
+8 -2

No files matched your search

+4 -1
View File
@@ -481,7 +481,10 @@ function isProcessAlive(pid: number): boolean {
try {
process.kill(pid, 0);
return true;
} catch {
} catch (error) {
const code = (error as NodeJS.ErrnoException)?.code;
if (code === "EPERM") return true;
if (code === "ESRCH") return false;
return false;
}
}
+4 -1
View File
@@ -129,7 +129,10 @@ function isProcessAlive(pid: number): boolean {
try {
process.kill(pid, 0);
return true;
} catch {
} catch (error) {
const code = (error as NodeJS.ErrnoException)?.code;
if (code === "EPERM") return true;
if (code === "ESRCH") return false;
return false;
}
}