mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-14 02:58:02 +00:00
proxmox-sys: import pipe() function from pbs-toos/src/io.rs
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
d357ce2070
commit
80df41a887
@ -24,6 +24,8 @@ macro_rules! identity {
|
||||
#[cfg(feature = "sortable-macro")]
|
||||
pub use proxmox_sortable_macro::sortable;
|
||||
|
||||
use fd::Fd;
|
||||
|
||||
/// Returns the hosts node name (UTS node name)
|
||||
pub fn nodename() -> &'static str {
|
||||
lazy_static::lazy_static! {
|
||||
@ -39,3 +41,10 @@ pub fn nodename() -> &'static str {
|
||||
|
||||
&NODENAME
|
||||
}
|
||||
|
||||
/// Safe wrapper for `nix::unistd::pipe2` defaulting to `O_CLOEXEC`
|
||||
/// and guarding the file descriptors.
|
||||
pub fn pipe() -> Result<(Fd, Fd), nix::Error> {
|
||||
let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?;
|
||||
Ok((Fd(pin), Fd(pout)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user