From 1613dd5332c66bcebb3e1b51c7d74664d7e186a1 Mon Sep 17 00:00:00 2001 From: reachableceo Date: Wed, 2 Sep 2026 21:45:44 -0500 Subject: [PATCH] =?UTF-8?q?fix(doorman):=20stdbuf=20cannot=20exec=20shell?= =?UTF-8?q?=20functions=20=E2=80=94=20buffer=20inside=20decode=5Fstream=20?= =?UTF-8?q?[#355]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deployment rehearsal on ultix-field 2026-09-02 caught it live: the listener showed active but decode_stream never ran (stdbuf exec's binaries only). Line-buffering moved inside decode_stream; the od stage keeps its own stdbuf. Rehearsal note: https://projects.knownelement.com/issues/355 --- bin/doorman.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/doorman.sh b/bin/doorman.sh index 17b35af..28a8d16 100755 --- a/bin/doorman.sh +++ b/bin/doorman.sh @@ -61,7 +61,10 @@ usage() { # behavior); Enter on an empty buffer emits nothing (defensive fix). # --------------------------------------------------------------------------- decode_stream() { # decode_stream — od -t u1 records on stdin -> IDs - awk -v w="$1" ' + # stdbuf exec's binaries only — it can NEVER wrap this function, so + # line-buffering happens here inside (piped awk block-buffers otherwise). + # shellcheck disable=SC2016 # awk program is single-quoted by design; '"$SELF"' re-opens quotes deliberately + stdbuf -oL awk -v w="$1" ' { if (NF != w) { next } ti = w - 7; ci = w - 5; vi = w - 3 @@ -143,7 +146,7 @@ stream_device() { log "listening on $dev (record width $WIDTH)" # stdbuf: od/awk block-buffer when piped; scans must not lag behind stdbuf -oL od -v -A n -t u1 -w"$WIDTH" "$dev" 2>/dev/null \ - | stdbuf -oL decode_stream "$WIDTH" \ + | decode_stream "$WIDTH" \ | while read -r bid; do process_scan "$bid" done