mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-14 07:05:47 +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")]
|
#[cfg(feature = "sortable-macro")]
|
||||||
pub use proxmox_sortable_macro::sortable;
|
pub use proxmox_sortable_macro::sortable;
|
||||||
|
|
||||||
|
use fd::Fd;
|
||||||
|
|
||||||
/// Returns the hosts node name (UTS node name)
|
/// Returns the hosts node name (UTS node name)
|
||||||
pub fn nodename() -> &'static str {
|
pub fn nodename() -> &'static str {
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
@ -39,3 +41,10 @@ pub fn nodename() -> &'static str {
|
|||||||
|
|
||||||
&NODENAME
|
&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