mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
fs/dup/dup2: don't add O_CLOEXEC for new file descriptor
refs: https://man7.org/linux/man-pages/man2/dup.2.html The two file descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
+4
-1
@@ -83,7 +83,10 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
|||||||
/* Then clone the file structure */
|
/* Then clone the file structure */
|
||||||
|
|
||||||
memset(&temp, 0, sizeof(temp));
|
memset(&temp, 0, sizeof(temp));
|
||||||
temp.f_oflags = filep1->f_oflags;
|
|
||||||
|
/* The two filep don't share flags (the close-on-exec flag). */
|
||||||
|
|
||||||
|
temp.f_oflags = filep1->f_oflags & ~O_CLOEXEC;
|
||||||
temp.f_pos = filep1->f_pos;
|
temp.f_pos = filep1->f_pos;
|
||||||
temp.f_inode = inode;
|
temp.f_inode = inode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user