Skip to content

fix: find stty on PATH for PTY resize - #98

Open
lmilojevicc wants to merge 1 commit into
nicobailon:mainfrom
lmilojevicc:fix/stty-from-path
Open

lmilojevicc wants to merge 1 commit into
nicobailon:mainfrom
lmilojevicc:fix/stty-from-path

Conversation

@lmilojevicc

Copy link
Copy Markdown

PTY resize spawns a hard-coded /usr/bin/stty. NixOS, Guix and some containers have no /usr/bin/stty (on NixOS it is /run/current-system/sw/bin/stty), so every resize fails with ENOENT:

  • the session keeps its starting size, so attaching to it, or resizing the terminal, leaves full-screen programs like watch or htop drawn at the wrong size;
  • each failure goes to console.error with the whole error object (stack, errno, spawnargs), which is printed over Pi's TUI.

This PR:

  • looks stty up on PATH, then falls back to /usr/bin/stty and /bin/stty (resolved once per process, resolveSttyPath in pty-process.ts);
  • reports a resize failure once per process, on one line: interactive-shell: PTY resize failed: <message>.

Tests: tests/stty-resolution.test.ts covers the lookup. On NixOS, PtyTerminalSession cleanup > supports descendant input and resize after the leader exits failed before this change and passes with it. Two other tests fail on this machine with or without the change (kill-session-suppression, shell-resolution); they look environment-specific and are unrelated. tsc -p tsconfig.json passes.

/usr/bin/stty does not exist on NixOS, Guix and some containers, so every
resize failed: sessions kept their starting size and each failure printed
the full error object over Pi's TUI. Look stty up on PATH, then fall back
to /usr/bin and /bin, and report a resize failure once, on one line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant