| commit | a4cf2ef40bdfb3e87c1295ec9390c4afd5b05b6d | [log] [tgz] |
|---|---|---|
| author | Matthew Maurer <mmaurer@google.com> | Tue Jun 14 15:48:28 2022 -0700 |
| committer | Matthew Maurer <mmaurer@google.com> | Tue Jun 14 15:48:28 2022 -0700 |
| tree | 5010dfb78a2e59c87c8880ee271516ba00c7e977 | |
| parent | e1c60ef5bd49024f9d9c350394a7d1204a19a749 [diff] |
Update TEST_MAPPING Test: None Bug: 236006683 Change-Id: I2670e189eb562609ba89a0973d162fd86f9da6b9
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.