Skip to content

🐛 fix(exec): pass stdin through to executed command#3842

Merged
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:3841
Mar 1, 2026
Merged

🐛 fix(exec): pass stdin through to executed command#3842
gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat:3841

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

Running commands via tox exec with piped stdin silently discards the input data. For example, echo "foo" | tox exec -- python -c 'import sys; print(sys.stdin.read())' produces an empty output instead of printing foo. This happens because StdinSource.user_only() returns OFF when sys.stdin.isatty() is False, mapping to DEVNULL in the subprocess Popen call.

When no_capture is enabled (which tox exec always sets), the subprocess should inherit the parent's stdin directly via StdinSource.USER rather than going through the tty check. This preserves the existing behavior for tox run while allowing tox exec to work naturally with pipes and redirections.

Fixes #3841

@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Mar 1, 2026
@gaborbernat gaborbernat enabled auto-merge (squash) March 1, 2026 14:24
`tox exec` discarded piped stdin because `StdinSource.user_only()`
returns OFF when stdin is not a tty. When `no_capture` is enabled
(always the case for `tox exec`), use `StdinSource.USER` directly
so the subprocess inherits the parent's stdin.

Fixes tox-dev#3841
@gaborbernat gaborbernat merged commit 86bba07 into tox-dev:main Mar 1, 2026
27 checks passed
@gaborbernat gaborbernat deleted the 3841 branch March 9, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided bug:normal affects many people or has quite an impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tox exec should pass stdin through

1 participant