• Home
Name Date Size #Lines LOC

..--

.github/workflows/03-May-2024-6256

examples/03-May-2024-7649

src/03-May-2024-455279

testdata/03-May-2024-22

.cargo_vcs_info.jsonD03-May-202494 66

.gitignoreD03-May-202428 43

Android.bpD03-May-20241,007 4137

CONTRIBUTING.mdD03-May-20241.1 KiB3021

Cargo.tomlD03-May-20241.1 KiB3833

Cargo.toml.origD03-May-2024611 2622

LICENSED03-May-202411.1 KiB202169

METADATAD03-May-2024431 2019

MODULE_LICENSE_APACHE2D03-May-20240

OWNERSD03-May-202440 21

README.mdD03-May-20241.3 KiB5038

TEST_MAPPINGD03-May-2024244 1211

cargo2android.jsonD03-May-202459 55

README.md

1# command-fds
2
3[![crates.io page](https://img.shields.io/crates/v/command-fds.svg)](https://crates.io/crates/command-fds)
4[![docs.rs page](https://docs.rs/command-fds/badge.svg)](https://docs.rs/command-fds)
5
6A library for passing arbitrary file descriptors when spawning child processes.
7
8## Example
9
10```rust
11use command_fds::{CommandFdExt, FdMapping};
12use std::fs::File;
13use std::os::unix::io::AsRawFd;
14use std::process::Command;
15
16// Open a file.
17let file = File::open("Cargo.toml").unwrap();
18
19// Prepare to run `ls -l /proc/self/fd` with some FDs mapped.
20let mut command = Command::new("ls");
21command.arg("-l").arg("/proc/self/fd");
22command
23    .fd_mappings(vec![
24        // Map `file` as FD 3 in the child process.
25        FdMapping {
26            parent_fd: file.as_raw_fd(),
27            child_fd: 3,
28        },
29        // Map this process's stdin as FD 5 in the child process.
30        FdMapping {
31            parent_fd: 0,
32            child_fd: 5,
33        },
34    ])
35    .unwrap();
36
37// Spawn the child process.
38let mut child = command.spawn().unwrap();
39child.wait().unwrap();
40```
41
42## License
43
44Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
45
46## Contributing
47
48If you want to contribute to the project, see details of
49[how we accept contributions](CONTRIBUTING.md).
50