| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| examples/ | 04-Jul-2025 | - | 78 | 51 | ||
| src/ | 04-Jul-2025 | - | 460 | 284 | ||
| testdata/ | 04-Jul-2025 | - | 2 | 2 | ||
| .android-checksum.json | D | 04-Jul-2025 | 1.3 KiB | 1 | 1 | |
| .cargo-checksum.json | D | 04-Jul-2025 | 914 | 1 | 1 | |
| Android.bp | D | 04-Jul-2025 | 947 | 37 | 33 | |
| CONTRIBUTING.md | D | 04-Jul-2025 | 1.1 KiB | 30 | 21 | |
| Cargo.lock | D | 04-Jul-2025 | 7.6 KiB | 291 | 255 | |
| Cargo.toml | D | 04-Jul-2025 | 1.1 KiB | 47 | 41 | |
| LICENSE | D | 04-Jul-2025 | 11.1 KiB | 202 | 169 | |
| METADATA | D | 04-Jul-2025 | 431 | 18 | 17 | |
| MODULE_LICENSE_APACHE2 | D | 04-Jul-2025 | 0 | |||
| README.md | D | 04-Jul-2025 | 1.3 KiB | 50 | 38 | |
| TEST_MAPPING | D | 04-Jul-2025 | 244 | 12 | 11 | |
| cargo_embargo.json | D | 04-Jul-2025 | 51 | 4 | 4 |
README.md
1# command-fds 2 3[](https://crates.io/crates/command-fds) 4[](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