INNER CODE UNIT · Rust
forward_stderr
jub0t/Concat · src/crates/concat-android/src/lib.rs:68
fn forward_stderr() {
use std::os::fd::FromRawFd;
let mut ends = [0i32; 2];
// SAFETY: plain libc calls on descriptors this function owns; the
// read end is handed to exactly one File.
let reader = unsafe {
if libc::pipe(ends.as_mut_ptr()) != 0 {
return;
}
if libc::dup2(ends[1], libc::STDERR_FILENO) < 0 {
libc::close(ends[0]);
libc::close(ends[1]);
return;
}
libc::close(ends[1]);
std::fs::File::from_raw_fd(ends[0])
};
std::thread::Builder::new()