Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
.github/workflows/ | 03-May-2024 | - | 62 | 56 | ||
examples/ | 03-May-2024 | - | 76 | 49 | ||
src/ | 03-May-2024 | - | 455 | 279 | ||
testdata/ | 03-May-2024 | - | 2 | 2 | ||
.cargo_vcs_info.json | D | 03-May-2024 | 94 | 6 | 6 | |
.gitignore | D | 03-May-2024 | 28 | 4 | 3 | |
Android.bp | D | 03-May-2024 | 1,007 | 41 | 37 | |
CONTRIBUTING.md | D | 03-May-2024 | 1.1 KiB | 30 | 21 | |
Cargo.toml | D | 03-May-2024 | 1.1 KiB | 38 | 33 | |
Cargo.toml.orig | D | 03-May-2024 | 611 | 26 | 22 | |
LICENSE | D | 03-May-2024 | 11.1 KiB | 202 | 169 | |
METADATA | D | 03-May-2024 | 431 | 20 | 19 | |
MODULE_LICENSE_APACHE2 | D | 03-May-2024 | 0 | |||
OWNERS | D | 03-May-2024 | 40 | 2 | 1 | |
README.md | D | 03-May-2024 | 1.3 KiB | 50 | 38 | |
TEST_MAPPING | D | 03-May-2024 | 244 | 12 | 11 | |
cargo2android.json | D | 03-May-2024 | 59 | 5 | 5 |
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