From 87b3530b293ed8635204d606cdca1b3756525fa1 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 14 Nov 2026 18:48:41 +0100 Subject: [PATCH] fix(tests): mods suite hung in a terminal, CLI under timeout now reads /dev/null --- lib/tests/mods.test.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tests/mods.test.sh b/lib/tests/mods.test.sh index f0efe1b..0ae2be2 100644 --- a/lib/tests/mods.test.sh +++ b/lib/tests/mods.test.sh @@ -17,13 +17,15 @@ ko() { fail=$((fail+1)); echo "FAIL $1"; } check() { if [ "$2" = "$3" ]; then ok "$1"; else ko "$1: got[$2] want[$3]"; fi; } # bounded CMD...: stdout+stderr on stdout, rc 124 on timeout. +# stdin from /dev/null: a CLI touching an inherited tty from timeout's +# background group gets SIGTTOU, which stops timeout too. bounded() { local t t=$(command -v timeout || command -v gtimeout || true) - if [ -n "$t" ]; then "$t" "$CLI_TIMEOUT" "$@" 2>&1; return; fi + if [ -n "$t" ]; then "$t" "$CLI_TIMEOUT" "$@" &1; return; fi local out rc=0 pid i=0 out=$(mktemp) || return 1 - "$@" >"$out" 2>&1 & pid=$! + "$@" "$out" 2>&1 & pid=$! while kill -0 "$pid" 2>/dev/null && [ "$i" -lt "$CLI_TIMEOUT" ]; do sleep 1; i=$((i+1)) done