commit | 26d5a67cc5ffd657322a32a1a4b560c89a6f5243 | [log] [tgz] |
---|---|---|
author | Jeff Vander Stoep <jeffv@google.com> | Tue Jan 31 21:51:49 2023 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Jan 31 21:51:49 2023 +0000 |
tree | 95ae6d3d23c33d4719bbd11a1b4fbbb3f260d6cd | |
parent | 02638f16574f1137fc3a986e4c598fe41e4ab5d8 [diff] | |
parent | 3f7dd0286b63738069cb18570700d85332e7ed86 [diff] |
Update TEST_MAPPING am: b0df4f9fb8 am: f526691628 am: 3f7dd0286b Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/command-fds/+/2411614 Change-Id: I4f63f23c3138d518283f2a99688a4c0ab07a2eec Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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.