mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 06:12:50 -07:00
fix(core): prevent race condition crash during shell auto-promotion
This commit is contained in:
@@ -1341,6 +1341,11 @@ export class ShellExecutionService {
|
||||
const activePty = this.activePtys.get(pid);
|
||||
const activeChild = this.activeChildProcesses.get(pid);
|
||||
|
||||
// If the process has already exited, there is no need to background it.
|
||||
if (!activePty && !activeChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
const resolvedSessionId =
|
||||
sessionId ?? activePty?.sessionId ?? activeChild?.sessionId;
|
||||
const resolvedCommand =
|
||||
|
||||
@@ -515,7 +515,13 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
||||
if (shouldAutoPromote && currentPid) {
|
||||
if (this._autoPromoteTimer) clearTimeout(this._autoPromoteTimer);
|
||||
this._autoPromoteTimer = setTimeout(() => {
|
||||
ShellExecutionService.background(currentPid!);
|
||||
const sessionId =
|
||||
this.context.config?.getSessionId?.() ?? 'default';
|
||||
ShellExecutionService.background(
|
||||
currentPid!,
|
||||
sessionId,
|
||||
strippedCommand,
|
||||
);
|
||||
}, waitMs);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user