summary refs log tree commit diff
path: root/sysdeps/posix/shm_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/shm_open.c')
-rw-r--r--sysdeps/posix/shm_open.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c
index f2961620b4..0182e7baf5 100644
--- a/sysdeps/posix/shm_open.c
+++ b/sysdeps/posix/shm_open.c
@@ -40,6 +40,11 @@ shm_open (const char *name, int oflag, mode_t mode)
 # ifdef O_CLOEXEC
   oflag |= O_CLOEXEC;
 # endif
+
+  /* Disable asynchronous cancellation.  */
+  int state;
+  pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
+
   int fd = open (shm_name, oflag, mode);
   if (fd == -1 && __glibc_unlikely (errno == EISDIR))
     /* It might be better to fold this error with EINVAL since
@@ -70,6 +75,8 @@ shm_open (const char *name, int oflag, mode_t mode)
     }
 # endif
 
+  pthread_setcancelstate (state, NULL);
+
   return fd;
 }