about summary refs log tree commit diff
path: root/sysdeps/posix/shm_open.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
commitcef9b65376a044309f74b77860ccf3c48a4ae315 (patch)
treec934a9b57903468b9a2754c1cf8f99f2a94c9269 /sysdeps/posix/shm_open.c
parentb48061e1a534a2421c65e4258418d41a5335ba32 (diff)
downloadglibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.xz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'sysdeps/posix/shm_open.c')
-rw-r--r--sysdeps/posix/shm_open.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c
index 56a9965263..64315de8f8 100644
--- a/sysdeps/posix/shm_open.c
+++ b/sysdeps/posix/shm_open.c
@@ -34,10 +34,7 @@ shm_open (const char *name, int oflag, mode_t mode)
 {
   SHM_GET_NAME (EINVAL, -1, "");
 
-  oflag |= O_NOFOLLOW;
-# ifdef O_CLOEXEC
-  oflag |= O_CLOEXEC;
-# endif
+  oflag |= O_NOFOLLOW | O_CLOEXEC;
 
   /* Disable asynchronous cancellation.  */
   int state;
@@ -50,29 +47,6 @@ shm_open (const char *name, int oflag, mode_t mode)
        object names and the standard does not mention EISDIR.  */
     __set_errno (EINVAL);
 
-# ifndef O_CLOEXEC
-  if (fd != -1)
-    {
-      /* We got a descriptor.  Now set the FD_CLOEXEC bit.  */
-      int flags = fcntl (fd, F_GETFD, 0);
-
-      if (__glibc_likely (flags != -1))
-	{
-	  flags |= FD_CLOEXEC;
-	  flags = fcntl (fd, F_SETFD, flags);
-	}
-
-      if (flags == -1)
-	{
-	  /* Something went wrong.  We cannot return the descriptor.  */
-	  int save_errno = errno;
-	  close (fd);
-	  fd = -1;
-	  __set_errno (save_errno);
-	}
-    }
-# endif
-
   pthread_setcancelstate (state, NULL);
 
   return fd;