passfd 0.1.6

File descriptor passing
Documentation
1
2
3
4
5
6
7
8
9
10
11
use passfd::FdPassingExt;
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::os::unix::net::UnixListener;

fn main() {
    let file = File::open("/etc/passwd").unwrap();
    let listener = UnixListener::bind("/tmp/test.sock").unwrap();
    let (stream, _) = listener.accept().unwrap();
    stream.send_fd(file.as_raw_fd()).unwrap();
}