pussuw commented on code in PR #16326: URL: https://github.com/apache/nuttx/pull/16326#discussion_r2076166283
########## include/nuttx/fs/fs.h: ########## @@ -462,6 +462,7 @@ struct file int f_oflags; /* Open mode flags */ #ifdef CONFIG_FS_REFCOUNT atomic_t f_refs; /* Reference count */ + sem_t f_closem; /* Free: file is fully closed */ Review Comment: Yes this would be better. However, it is not clear to me which implementation is correct. POSIX says `The dup2() function shall cause the file descriptor fildes2 to refer to the same open file description as the file descriptor fildes and to share any locks, and shall return fildes2.` NuttX dup2/3 uses two file structs for oldfd and newfd, so they don't point to different file structs and do not share file status or offset. Linux does this differently, dup2/3 makes filep2 = filep1, and when accessing fd1 and fd2 the file status and position change for both descriptors (as they are the same file struct). Which is correct ? The POSIX spec is ambiguous in this respect. I think our implementation is wrong but changing this functionality can create a MASSIVE regression for people who depend on our (wrong) implementation of dup2/3. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org