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:
2 files changed
+8
-2
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user