本文簡要介紹rust語言中 Struct std::os::linux::process::PidFd
的用法。
用法
pub struct PidFd { /* fields omitted */ }
此類型表示引用進程的文件說明符。
PidFd
可以通過在 Command
上使用 create_pidfd
設置相應的選項來獲得。隨後,可以通過調用 pidfd
或 take_pidfd
從 Child
中檢索創建的 pidfd。
例子:
#![feature(linux_pidfd)]
use std::os::linux::process::{CommandExt, ChildExt};
use std::process::Command;
let mut child = Command::new("echo")
.create_pidfd(true)
.spawn()
.expect("Failed to spawn child");
let pidfd = child
.take_pidfd()
.expect("Failed to retrieve pidfd");
// The file descriptor will be closed when `pidfd` is dropped.
有關詳細信息,請參閱 pidfd_open(2)
的手冊頁。
相關用法
- Rust Pin.new_unchecked用法及代碼示例
- Rust Pin.as_mut用法及代碼示例
- Rust PanicInfo.payload用法及代碼示例
- Rust Path.components用法及代碼示例
- Rust PathBuf.with_capacity用法及代碼示例
- Rust Poll.map用法及代碼示例
- Rust Peekable.peek用法及代碼示例
- Rust Path.is_symlink用法及代碼示例
- Rust Poll.map_ok用法及代碼示例
- Rust Pointer用法及代碼示例
- Rust Path.canonicalize用法及代碼示例
- Rust PartialOrd.partial_cmp用法及代碼示例
- Rust Path.is_relative用法及代碼示例
- Rust Path.file_stem用法及代碼示例
- Rust PermissionsExt.set_mode用法及代碼示例
- Rust Path.to_string_lossy用法及代碼示例
- Rust Path.display用法及代碼示例
- Rust PathBuf.into_os_string用法及代碼示例
- Rust Peekable.next_if用法及代碼示例
- Rust PanicInfo用法及代碼示例
- Rust PathBuf.pop用法及代碼示例
- Rust Path.ancestors用法及代碼示例
- Rust Path用法及代碼示例
- Rust Path.is_dir用法及代碼示例
- Rust Path.strip_prefix用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 Struct std::os::linux::process::PidFd。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。