Source: external review report, 2026-08-24 (severity: Medium)
Problem
src/shell.sh:355:
IFS= read -r -n1 -d '' -t 1 _k || true
and src/shell.sh:479 if [[ -z "$_key" ]]; then treats an empty key as a timeout tick.
When read returns EOF (tty detached, stdin redirected from a closed source, ptyunit harness edge) it returns instantly with _key="", which the loop handles identically to a 1s timeout → tight loop at 100% CPU for as long as /dev/tty stays open.
What it needs
- Distinguish timeout from EOF:
read -t returns >128 on timeout; EOF returns 1 with empty result. Check $? rather than only $_key.
- On EOF: quit the loop cleanly (same path as
q), non-zero exit code
Validation note (per org standards): fd/EOF behavior must be verified against a real PTY, not reasoned about — write the ptyunit test first and confirm the read return codes on bash 3.2 and 5.x in the Docker matrix.
Tests
- ptyunit: close the slave side mid-loop → process exits within one tick, CPU not pegged
Effort: S
Deps: none
Priority: pre-OSS-launch blocker (one of #41/#42/#43/#44)
Source: external review report, 2026-08-24 (severity: Medium)
Problem
src/shell.sh:355:and
src/shell.sh:479if [[ -z "$_key" ]]; thentreats an empty key as a timeout tick.When
readreturns EOF (tty detached, stdin redirected from a closed source, ptyunit harness edge) it returns instantly with_key="", which the loop handles identically to a 1s timeout → tight loop at 100% CPU for as long as/dev/ttystays open.What it needs
read -treturns >128 on timeout; EOF returns 1 with empty result. Check$?rather than only$_key.q), non-zero exit codeValidation note (per org standards): fd/EOF behavior must be verified against a real PTY, not reasoned about — write the ptyunit test first and confirm the
readreturn codes on bash 3.2 and 5.x in the Docker matrix.Tests
Effort: S
Deps: none
Priority: pre-OSS-launch blocker (one of #41/#42/#43/#44)