fix: prevent statusline hook from hanging on stdin#27
Merged
graykode merged 3 commits intograykode:mainfrom Apr 4, 2026
Merged
fix: prevent statusline hook from hanging on stdin#27graykode merged 3 commits intograykode:mainfrom
graykode merged 3 commits intograykode:mainfrom
Conversation
Two fixes for abtop-statusline.sh: 1. Replace `cat` with `read -t 5` loop — avoids blocking indefinitely when stdin isn't closed. Works on both macOS and Linux (unlike `timeout` which needs coreutils). 2. Pipe JSON to python via stdin instead of passing as a CLI argument — avoids hitting ARG_MAX on large payloads and breaking on special characters in the JSON. Fixes graykode#15
Owner
|
Thanks for tackling #15! The approach is solid —
Could you address 1 and 2? |
fa28c02 to
6af46b1
Compare
Address review feedback: - Replace echo with printf '%s' to avoid interpreting escapes/flags - Preserve newline separators when concatenating read lines
6af46b1 to
942b792
Compare
Add || [ -n "$line" ] guard so the read loop captures the final chunk when stdin closes without a trailing newline.
graykode
approved these changes
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes for
abtop-statusline.shthat address #15:Hang fix: replace
INPUT=$(cat)with aread -r -t 5loop — the script now times out after 5 seconds instead of blocking indefinitely when stdin isn't closed. Uses bash builtins only, works on both macOS and Linux (nocoreutilsdependency).Large payload fix: pipe JSON to python via stdin (
json.load(sys.stdin)) instead of passing it as a CLI argument (sys.argv[1]). Avoids hittingARG_MAXon large status payloads and prevents breakage from special characters in the JSON.Users need to re-run
abtop --setupafter updating to regenerate the hook script.Fixes #15
Test plan
abtop-rate-limits.jsonrate_limitskey → exits cleanly/dev/nullstdin → exits instantlycargo clippy -- -D warningspassescargo test— 25/25 pass