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

View File

@@ -22,4 +22,6 @@
(literal "/dev/stdout")
(literal "/dev/stderr")
(literal "/dev/null")
)
(literal "/dev/ptmx")
(regex #"^/dev/ttys[0-9]*$")
)

View File

@@ -678,19 +678,28 @@ export class ShellExecutionService {
return { pid: ptyProcess.pid, result };
} catch (e) {
const error = e as Error;
return {
pid: undefined,
result: Promise.resolve({
error,
rawOutput: Buffer.from(''),
output: '',
exitCode: 1,
signal: null,
aborted: false,
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,
executionMethod: 'none',
}),
};
result: Promise.resolve({
error,
rawOutput: Buffer.from(''),
output: '',
exitCode: 1,
signal: null,
aborted: false,
pid: undefined,
executionMethod: 'none',
}),
};
}
}
}