From c11d9254a21f3ad84d5916798cc74ebe5c401de7 Mon Sep 17 00:00:00 2001 From: Charley Wu Date: Mon, 27 Jul 2026 23:01:51 +0800 Subject: [PATCH] fix: prevent statusline example script from hanging on blocked stdin The example script read stdin unbounded (jq reading directly from the live pipe). During auth/OAuth refresh or resume-conversation warm-up, the CLI's statusline runner can hold stdin open without writing or closing it, so the script hangs until the runner's ~5-10s hard kill (signal: killed), and enough consecutive kills auto-disables the custom statusline. Read stdin with a short timeout up front, close it immediately after (exec 0/dev/null 2>&1; then + timeout --foreground "$t" "$@" + else + "$@" <&0 & + local pid=$! + ( sleep "$t"; kill "$pid" 2>/dev/null || true ) & + local killer=$! + wait "$pid" 2>/dev/null + local res=$? + kill "$killer" 2>/dev/null || true + wait "$killer" 2>/dev/null || true + return $res + fi +} + +JSON_INPUT=$(run_with_timeout 0.25 cat 2>/dev/null || true) +exec 0