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

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


The following commit(s) were added to refs/heads/master by this push:
     new e9d7210d02 sim/posix_test: fix shm_open() return file descriptor 
associated with FD_CLOEXEC
e9d7210d02 is described below

commit e9d7210d02b57b666e6ca6c63f0eb8ea8295b007
Author: yanghuatao <[email protected]>
AuthorDate: Wed Jun 21 19:47:14 2023 +0800

    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 <[email protected]>
---
 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 6274e460ed..8f75d92fd5 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:

Reply via email to