本文简要介绍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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。