Fix --no-input hang when stdin is a socket or non-pipe fd - #1016
Open
harriiinnii wants to merge 2 commits into
Open
Fix --no-input hang when stdin is a socket or non-pipe fd#1016harriiinnii wants to merge 2 commits into
harriiinnii wants to merge 2 commits into
Conversation
StdinHasData() returned true for any non-terminal fd, including Unix socket pairs and character devices. This caused --no-input commands (e.g. `jira issue create`) to call io.ReadAll(os.Stdin) and block forever on a socket that never sends EOF. Narrow the check so only pipes (ModeNamedPipe) and regular files are treated as having data. Terminals, sockets, character devices, and other special files now return false, matching the expected semantics of "is there piped/redirected data ready to read?". Fixes ankitpokhrel#948 Fixes ankitpokhrel#984
The previous commit accidentally stripped � from the color format strings in Success(), Warn(), and Fail(). Those functions were not part of the intended change and are restored verbatim from the base. The only functional change is StdinHasData(): narrow the non-terminal check to named pipes and regular files so stdin sockets do not block.
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.
Problem
jira issue create --no-input(andjira issue comment add --no-input) hangs indefinitely when the process is invoked from a subprocess context where stdin is a Unix socket pair, a character device, or any other non-pipe, non-file fd.StdinHasData()returnedtruefor any non-terminal fd:This caused
ReadFile("")to callio.ReadAll(os.Stdin)and block forever, because socket pairs only return EOF when the peer explicitly shuts down the write half — which automation tools typically do not do.Fix
Narrow the
StdinHasData()check so it returnstrueonly when stdin is a named pipe (os.ModeNamedPipe) or a regular file (mode.IsRegular()). This matches the actual intent — "did the caller pipe or redirect data?" — and leaves sockets, character devices, and other special files returningfalse.Both common use cases continue to work as before:
echo "body" | jira issue create ...— pipe, returnstruejira issue create ... < body.txt— regular file, returnstrueFixes #948
Fixes #984