fs/dup3: impletement dup3/nx_dup3_from_tcb function

refs: https://man7.org/linux/man-pages/man2/dup.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2023-10-22 16:53:58 +08:00
committed by Xiang Xiao
parent dc2dac2377
commit 73dc8f84cc
7 changed files with 184 additions and 86 deletions
+3 -1
View File
@@ -33,6 +33,7 @@
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <fcntl.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
@@ -175,7 +176,8 @@ static void local_recvctl(FAR struct local_conn_s *conn,
count = peer->lc_cfpcount;
for (i = 0; i < count; i++)
{
fds[i] = file_dup(peer->lc_cfps[i], 0, !!(flags & MSG_CMSG_CLOEXEC));
fds[i] = file_dup(peer->lc_cfps[i], 0,
flags & MSG_CMSG_CLOEXEC ? O_CLOEXEC : 0);
file_close(peer->lc_cfps[i]);
kmm_free(peer->lc_cfps[i]);
peer->lc_cfps[i] = NULL;