This is an automated email from the ASF dual-hosted git repository.

abudnik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 360e8838d08eb07496b2c3e6bcd511348ce488b0
Author: Andrei Budnik <abud...@apache.org>
AuthorDate: Fri Feb 21 12:08:47 2020 +0100

    Removed reimplementation of `cloexec` from systemd activation code.
    
    Review: https://reviews.apache.org/r/72157
---
 src/linux/systemd.cpp | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/linux/systemd.cpp b/src/linux/systemd.cpp
index 9897473..c7815a0 100644
--- a/src/linux/systemd.cpp
+++ b/src/linux/systemd.cpp
@@ -337,30 +337,6 @@ Try<Nothing> start(const string& name)
 
 namespace socket_activation {
 
-static Try<Nothing> setCloexecFlag(int fd, bool cloexec)
-{
-  CHECK(fd >= 0) << "Invalid file desciptor was passed";
-
-  int flags = ::fcntl(fd, F_GETFD, 0);
-  if (flags < 0) {
-    return ErrnoError();
-  }
-
-  int nflags = cloexec == true ? flags | FD_CLOEXEC
-                               : flags & ~FD_CLOEXEC;
-
-  if (nflags == flags) {
-    return Nothing();
-  }
-
-  if (::fcntl(fd, F_SETFD, nflags) < 0) {
-    return ErrnoError();
-  }
-
-  return Nothing();
-}
-
-
 // See `src/libsystemd/sd-daemon/sd-daemon.c` in the systemd source tree
 // for the reference implementation. We follow that implementation to
 // decide which conditions should result in errors and which should return
@@ -404,7 +380,7 @@ Try<std::vector<int>> listenFds()
   }
 
   for (int fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; ++fd) {
-    Try<Nothing> cloexec = setCloexecFlag(fd, true);
+    Try<Nothing> cloexec = os::cloexec(fd);
     if (cloexec.isError()) {
       return Error(
           "Could not set CLOEXEC flag for file descriptor " + stringify(fd) +

Reply via email to