drop fd_change_cloexec from proxmox-rest-server
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
6d4e47fb09
commit
249aae1f05
@ -16,7 +16,7 @@ use nix::unistd::{fork, ForkResult};
|
||||
use proxmox::tools::io::{ReadExt, WriteExt};
|
||||
use proxmox::tools::fd::Fd;
|
||||
|
||||
use crate::fd_change_cloexec;
|
||||
use pbs_tools::fd::fd_change_cloexec;
|
||||
|
||||
#[link(name = "systemd")]
|
||||
extern "C" {
|
||||
|
@ -1,4 +1,3 @@
|
||||
use std::os::unix::io::RawFd;
|
||||
use std::sync::atomic::{Ordering, AtomicBool};
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
@ -135,16 +134,6 @@ pub fn fail_on_shutdown() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Helper to set/clear the FD_CLOEXEC flag on file descriptors
|
||||
pub fn fd_change_cloexec(fd: RawFd, on: bool) -> Result<(), Error> {
|
||||
use nix::fcntl::{fcntl, FdFlag, F_GETFD, F_SETFD};
|
||||
let mut flags = FdFlag::from_bits(fcntl(fd, F_GETFD)?)
|
||||
.ok_or_else(|| format_err!("unhandled file flags"))?; // nix crate is stupid this way...
|
||||
flags.set(FdFlag::FD_CLOEXEC, on);
|
||||
fcntl(fd, F_SETFD(flags))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// safe wrapper for `nix::sys::socket::socketpair` defaulting to `O_CLOEXEC` and guarding the file
|
||||
/// descriptors.
|
||||
pub fn socketpair() -> Result<(Fd, Fd), Error> {
|
||||
|
Loading…
Reference in New Issue
Block a user