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