fix(desktop): shut down cleanly with workspace terminals (#3268)
Workspace terminal shutdown only signaled an npm wrapper, leaving Electron alive with broken output pipes. Make the signal-handling runner the terminal-owned process and route external Electron termination through the existing quit lifecycle.
This commit is contained in:
@@ -14,6 +14,10 @@ interface BeforeQuitApp {
|
||||
exit(code: number): void;
|
||||
}
|
||||
|
||||
interface ExternalQuitSignalSource {
|
||||
on(signal: NodeJS.Signals, listener: () => void): unknown;
|
||||
}
|
||||
|
||||
interface QuitLifecycle {
|
||||
handleBeforeQuit(event: BeforeQuitEvent): void;
|
||||
handleBeforeQuitForUpdate(): void;
|
||||
@@ -31,6 +35,23 @@ export interface StopOnQuitDeps {
|
||||
showShutdownFeedback: () => void;
|
||||
}
|
||||
|
||||
export function registerExternalQuitSignals({
|
||||
signals,
|
||||
quit,
|
||||
}: {
|
||||
signals: ExternalQuitSignalSource;
|
||||
quit: () => void;
|
||||
}): void {
|
||||
let quitRequested = false;
|
||||
for (const signal of ["SIGHUP", "SIGINT", "SIGTERM"] satisfies NodeJS.Signals[]) {
|
||||
signals.on(signal, () => {
|
||||
if (quitRequested) return;
|
||||
quitRequested = true;
|
||||
quit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldStopDesktopManagedDaemonOnQuit(settings: QuitLifecycleSettings): boolean {
|
||||
return !settings.daemon.keepRunningAfterQuit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user