Closed
Description
Problem
When exec
ing e.g. cargo build
with a closed stdin
file descriptor, it panics with:
thread '<unnamed>' panicked at 'failed to acquire jobserver token: early EOF on jobserver pipe', src/librustc_codegen_ssa/back/write.rs:1348:29
Expected behavior: cargo
should treat this the same as if stdin
was a valid file descriptor that nothing gets written to.
Steps
This can be reproduced e.g. by a rust program that:
- calls
libc::close(libc::STDIN_FILENO)
, - calls
nix::unistd::execvp
to runcargo build
on a project.
Here's an example repo including a reproduce.sh
script to show the bug: https://github.com/soenkehahn/entr-cargo-bug
Possible Solution(s)
I think cargo
could check with fcntl(libc::STDIN_FILENO, libc::F_GETFD)
whether stdin
is still open.
Notes
This is motivated by trying to use cargo
in conjunction with entr
. Since this commit it closes the stdin
of the called command when using the -r
(restart) option.
Output of cargo version
:
cargo 1.33.0 (f099fe94b 2019-02-12)
On linux.