diff --git a/fs/vfs/fs_dup2.c b/fs/vfs/fs_dup2.c index 82573826602..95ad2a4d1b5 100644 --- a/fs/vfs/fs_dup2.c +++ b/fs/vfs/fs_dup2.c @@ -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;