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:
parent
5c98649a7a
commit
dc2dac2377
1 changed files with 4 additions and 1 deletions
|
@ -83,7 +83,10 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
|||
/* Then clone the file structure */
|
||||
|
||||
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_inode = inode;
|
||||
|
||||
|
|
Loading…
Reference in a new issue