commit | b0df4f9fb891f9319a64163b352f3586a26e6c6e | [log] [tgz] |
---|---|---|
author | Jeff Vander Stoep <jeffv@google.com> | Mon Jan 30 11:07:54 2023 +0100 |
committer | Jeff Vander Stoep <jeffv@google.com> | Mon Jan 30 11:07:54 2023 +0100 |
tree | 95ae6d3d23c33d4719bbd11a1b4fbbb3f260d6cd | |
parent | f63734e47b3b87775781bb8c12b4549b374441a6 [diff] |
Update TEST_MAPPING Test: atest Change-Id: Iae4c5131bb45ffe05ea6e98e11a3439b352db8cf
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.