commit | 72193c9d0bf02710cdf0dedc12ce0b885ef7e46e | [log] [tgz] |
---|---|---|
author | Jiyong Park <[email protected]> | Fri Aug 16 18:48:28 2024 +0900 |
committer | Jiyong Park <[email protected]> | Fri Aug 16 18:52:14 2024 +0900 |
tree | bcfdeddd10fa07021a5ae341b647eea94cede139 | |
parent | 6acf7648b16ff1391f8f00523d338a8453618cbe [diff] |
Upgrade command-fds to 0.3.0 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/rust/crates/command-fds For more info, check https://cs.android.com/android/platform/superproject/main/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I5a622b7a15d699dfb85d18768d63046a92537c54
A library for passing arbitrary file descriptors when spawning child processes.
use command_fds::{CommandFdExt, FdMapping}; use std::fs::File; use std::os::unix::io::AsRawFd; use std::process::Command; // Open a file. let file = File::open("Cargo.toml").unwrap(); // Prepare to run `ls -l /proc/self/fd` with some FDs mapped. let mut command = Command::new("ls"); command.arg("-l").arg("/proc/self/fd"); command .fd_mappings(vec![ // Map `file` as FD 3 in the child process. FdMapping { parent_fd: file.as_raw_fd(), child_fd: 3, }, // Map this process's stdin as FD 5 in the child process. FdMapping { parent_fd: 0, child_fd: 5, }, ]) .unwrap(); // Spawn the child process. let mut child = command.spawn().unwrap(); child.wait().unwrap();
Licensed under the Apache License, Version 2.0.
If you want to contribute to the project, see details of how we accept contributions.