-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Issue originally reported by @knsd.
Command::open
uses select
on Linux:
rust/src/libstd/sys/unix/pipe.rs
Line 90 in 4465f22
libc::select(max + 1, &mut read, ptr::null_mut(), ptr::null_mut(), |
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
retep998
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.