libc:lib_psfa_dddup2,add return check

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2022-09-14 16:13:03 +08:00 committed by Petro Karashchenko
parent 367fa640c1
commit fcdc7afcb5

View file

@ -89,8 +89,17 @@ int posix_spawn_file_actions_adddup2(
/* NOTE: Workaround to avoid an error when executing dup2 action */
flags = fcntl(fd1, F_GETFD);
if (flags < 0)
{
return flags;
}
flags &= ~FD_CLOEXEC;
fcntl(fd1, F_SETFD, flags);
flags = fcntl(fd1, F_SETFD, flags);
if (flags < 0)
{
return flags;
}
/* And add it to the file action list */