From e9d7210d02b57b666e6ca6c63f0eb8ea8295b007 Mon Sep 17 00:00:00 2001 From: yanghuatao Date: Wed, 21 Jun 2023 19:47:14 +0800 Subject: [PATCH] sim/posix_test: fix shm_open() return file descriptor associated with FD_CLOEXEC Make the pthread_setspecific pass the shm_open/11-1.c testcases. Function shm_open() should return a file descriptor for the shared memory object associated with FD_CLOEXEC. Reference to https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html and https://github.com/lattera/glibc/blob/master/sysdeps/posix/shm_open.c#LL38C1-L38C1 Signed-off-by: yanghuatao --- fs/shm/shm_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/shm/shm_open.c b/fs/shm/shm_open.c index 6274e460ed5..8f75d92fd57 100644 --- a/fs/shm/shm_open.c +++ b/fs/shm/shm_open.c @@ -142,7 +142,7 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name, /* Associate the inode with a file structure */ memset(shm, 0, sizeof(*shm)); - shm->f_oflags = oflags; + shm->f_oflags = oflags | O_CLOEXEC | O_NOFOLLOW; shm->f_inode = inode; errout_with_sem: