Fix stdin hang in non-TTY environments (sockets, PTY slaves) - #18
Open
rethab wants to merge 3 commits into
Open
Conversation
StdinHasData() treated any non-terminal fd as having data to read, including sockets and open PTY slaves that never signal EOF. This caused issue create/edit, epic create, and comment add (even with --no-input) to hang forever when stdin was such a descriptor in non-TTY environments like subprocesses or CI runners. Now only regular files and named pipes are considered to have data; anything else falls back to no data instead of blocking on read.
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.
StdinHasData() only checked whether stdin was a terminal and treated every other file descriptor as having data ready to read. That is true for regular files and pipes, but not for sockets or open PTY slaves, which never signal EOF. When stdin was one of those descriptors, commands that read the description/body from stdin (issue create, epic create, comment add, issue edit) would block forever on io.ReadAll, even when --no-input was passed, since the stdin read happens unconditionally before the no-input check.
This changes StdinHasData() to stat stdin and only report data available for regular files and named pipes, falling back to false for everything else (including on stat errors), so callers skip the blocking read instead of hanging.
Addresses ankitpokhrel#948.