Fix Codex keyboard input when launching from a piped installer (#65093)

## Why

When the installer runs through a pipe, Codex inherits the pipe as
standard input and cannot read keystrokes from the terminal.

## What changed

Keep standard input when it is already a terminal. Otherwise, launch
Codex with input from `/dev/tty`. On macOS, open the controlling
terminal device directly because polling `/dev/tty` for keyboard events
is unsupported.

GitOrigin-RevId: 382436320b801f499dd8ae3de288f42c4cb503f2
This commit is contained in:
Eric Traut authored and copyberry committed 2026-12-01 21:55:16 +00:00
1 parent a183b449e6
commit 30fdd9bd68
1 file changed
+9 -1
+9 -1
View File
@@ -1085,7 +1085,15 @@ print_launch_instructions() {
maybe_launch_codex_now() {
if prompt_yes_no "Start Codex now?"; then
step "Launching Codex"
"$BIN_PATH"
if [ -t 0 ]; then
"$BIN_PATH"
elif [ "$os" = "darwin" ]; then
# macOS can't poll /dev/tty for keyboard events. Open the controlling device directly.
launch_tty="$(ps -p "$$" -o tty= | awk '{print $1}')"
"$BIN_PATH" <"/dev/$launch_tty"
else
"$BIN_PATH" </dev/tty
fi
fi
}