cargo panics when stdin to it is closed #6723
Labels
A-console-output
Area: Terminal output, colors, progress bar, etc.
A-jobserver
Area: jobserver, concurrency, parallelism
C-bug
Category: bug
Problem
When
execing e.g.cargo buildwith a closedstdinfile descriptor, it panics with:Expected behavior:
cargoshould treat this the same as ifstdinwas a valid file descriptor that nothing gets written to.Steps
This can be reproduced e.g. by a rust program that:
libc::close(libc::STDIN_FILENO),nix::unistd::execvpto runcargo buildon a project.Here's an example repo including a
reproduce.shscript to show the bug: https://github.com/soenkehahn/entr-cargo-bugPossible Solution(s)
I think
cargocould check withfcntl(libc::STDIN_FILENO, libc::F_GETFD)whetherstdinis still open.Notes
This is motivated by trying to use
cargoin conjunction withentr. Since this commit it closes thestdinof the called command when using the-r(restart) option.Output of
cargo version:cargo 1.33.0 (f099fe94b 2019-02-12)On linux.
The text was updated successfully, but these errors were encountered: