From 935ee97b175b119e9c9aa7f235d338f72753c942 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 30 Nov 2020 10:58:26 +0100 Subject: [PATCH] use fd_change_cloexec helper Signed-off-by: Wolfgang Bumiller --- src/api2/node.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/api2/node.rs b/src/api2/node.rs index 6c3e7967..dcde83df 100644 --- a/src/api2/node.rs +++ b/src/api2/node.rs @@ -6,7 +6,6 @@ use futures::future::{FutureExt, TryFutureExt}; use hyper::body::Body; use hyper::http::request::Parts; use hyper::upgrade::Upgraded; -use nix::fcntl::{fcntl, FcntlArg, FdFlag}; use serde_json::{json, Value}; use tokio::io::{AsyncBufReadExt, BufReader}; @@ -145,18 +144,10 @@ async fn termproxy( move |worker| async move { // move inside the worker so that it survives and does not close the port // remove CLOEXEC from listenere so that we can reuse it in termproxy - let fd = listener.as_raw_fd(); - let mut flags = match fcntl(fd, FcntlArg::F_GETFD) { - Ok(bits) => FdFlag::from_bits_truncate(bits), - Err(err) => bail!("could not get fd: {}", err), - }; - flags.remove(FdFlag::FD_CLOEXEC); - if let Err(err) = fcntl(fd, FcntlArg::F_SETFD(flags)) { - bail!("could not set fd: {}", err); - } + tools::fd_change_cloexec(listener.as_raw_fd(), false)?; let mut arguments: Vec<&str> = Vec::new(); - let fd_string = fd.to_string(); + let fd_string = listener.as_raw_fd().to_string(); arguments.push(&fd_string); arguments.extend_from_slice(&[ "--path",