From 345f3f397d313173fbf7ade4b012915bddd30169 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 14 May 2026 15:39:05 -0400 Subject: [PATCH] fix: set stty -icanon -echo in bash script before exec sbcl uiop:run-program inside SBCL can't access the terminal, so stty calls from within Lisp fail silently. By running 'stty -icanon -echo' in the bash script before exec sbcl, the terminal is already in character-at-a-time mode when the TUI starts, and Ctrl+P/B keys arrive as individual bytes through the cat pipe. --- org/channel-tui-main.org | 8 ++------ passepartout | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/org/channel-tui-main.org b/org/channel-tui-main.org index 2ebb734..a96403d 100644 --- a/org/channel-tui-main.org +++ b/org/channel-tui-main.org @@ -910,12 +910,8 @@ Event handlers + daemon I/O + main loop. ;; breaks read on fd 0 in this SBCL environment, but -echo alone ;; works. A cat subprocess inherits the terminal and provides ;; bytes through a pipe that SBCL reads reliably. - ;; Enable character-at-a-time input (-icanon) so Ctrl+P/B - ;; arrive as individual bytes instead of being buffered. - ;; SBCL now reads from cat's pipe, not directly from fd 0, - ;; so -icanon doesn't trigger the SBCL read block issue. - (uiop:run-program '("stty" "-icanon" "-echo") - :output nil :ignore-error-status t) + ;; stty -icanon -echo is set by the bash script before exec sbcl. + ;; A cat subprocess reads keyboard input from the terminal. (let* ((cat-proc (uiop:launch-program '("cat") :output :stream :input :interactive diff --git a/passepartout b/passepartout index 3febe3f..86dbe90 100755 --- a/passepartout +++ b/passepartout @@ -410,6 +410,9 @@ LISPEOF # (SBCL strips COLUMNS/LINES but leaves MY_* alone). ts=$(stty size 2>/dev/null) export MY_TERM_ROWS="${ts%% *}" MY_TERM_COLS="${ts##* }" + # Set character-at-a-time mode BEFORE SBCL starts + # (uiop:run-program inside SBCL can't access the terminal) + stty -icanon -echo 2>/dev/null # Clear stale cl-tty cache to ensure latest backend-size fixes find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null exec sbcl --noinform --load /tmp/tui-load.lisp