Closed
Description
Issue originally reported by @knsd.
Command::open
uses select
on Linux:
rust/src/libstd/sys/unix/pipe.rs
Line 90 in 4465f22
select
is limited to file descriptors less than FD_SETSIZE
(1024).
Thus, if you raise ulimit -n
to more than 1024, the following code panics
use std::fs::File;
use std::process::Command;
const FD_SETSIZE: usize = 1024;
const STDIO: usize = 3;
const EXE: &'static str = "/usr/bin/env";
fn main() {
let mut files = Vec::new();
for _ in 0..FD_SETSIZE - STDIO * 2 {
let file = File::open(&EXE).unwrap();
files.push(file)
}
let output = Command::new(EXE).output();
println!("{:?}", output)
}
thread 'main' panicked at 'index out of bounds: the len is 16 but the index is 16', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/slice.rs:664