mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
rt: Set shm_open as a non cancellation point (BZ #18243)
This patch changes shm_open to not act as a cancellation point. Cancellation is disable at start and reenable in function exit. It fixes BZ #18243. Tested on x86_64 and i686. [BZ #18243] * rt/Makefile (test): Add tst-shm-cancel. * rt/tst-shm-cancel.c: New file. * sysdeps/posix/shm_open.c: Disable asynchronous cancellation.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user