• Home
Name Date Size #Lines LOC

..--

examples/04-Jul-2025-7851

src/04-Jul-2025-460284

testdata/04-Jul-2025-22

.android-checksum.jsonD04-Jul-20251.3 KiB11

.cargo-checksum.jsonD04-Jul-2025914 11

Android.bpD04-Jul-2025947 3733

CONTRIBUTING.mdD04-Jul-20251.1 KiB3021

Cargo.lockD04-Jul-20257.6 KiB291255

Cargo.tomlD04-Jul-20251.1 KiB4741

LICENSED04-Jul-202511.1 KiB202169

METADATAD04-Jul-2025431 1817

MODULE_LICENSE_APACHE2D04-Jul-20250

README.mdD04-Jul-20251.3 KiB5038

TEST_MAPPINGD04-Jul-2025244 1211

cargo_embargo.jsonD04-Jul-202551 44

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