commit | 9bff5ed8a5d23dbf79eadab59311ff7a6c62f21a | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Tue May 25 21:01:57 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue May 25 21:01:57 2021 +0000 |
tree | 38d4b7e468f4b5ce30b64ceae4343ee50c94896a | |
parent | f7fbceda7390207781df450e65bdc61609fbac40 [diff] | |
parent | 5fcba4be92639309a5d6a79404d7905f6e9b0c11 [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/command-fds am: 959539b471 am: 5fcba4be92 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/command-fds/+/1718370 Change-Id: Iba0fa8163842b5805e77cc53c23218bd9a68d63d
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.