fix(core): Handle PTY spawn errors in macOS sandbox (#11539)

This commit is contained in:
Gal Zahavi
2025-10-20 17:14:27 -07:00
committed by GitHub
parent 723b8d33c2
commit 72b16b3a24
2 changed files with 24 additions and 13 deletions
@@ -22,4 +22,6 @@
(literal "/dev/stdout")
(literal "/dev/stderr")
(literal "/dev/null")
(literal "/dev/ptmx")
(regex #"^/dev/ttys[0-9]*$")
)
@@ -678,6 +678,14 @@ export class ShellExecutionService {
return { pid: ptyProcess.pid, result };
} catch (e) {
const error = e as Error;
if (error.message.includes('posix_spawnp failed')) {
onOutputEvent({
type: 'data',
chunk:
'[GEMINI_CLI_WARNING] PTY execution failed, falling back to child_process. This may be due to sandbox restrictions.\n',
});
throw e;
} else {
return {
pid: undefined,
result: Promise.resolve({
@@ -693,6 +701,7 @@ export class ShellExecutionService {
};
}
}
}
/**
* Writes a string to the pseudo-terminal (PTY) of a running process.