New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow o_cloexe semantics when calling the exec function #11036
Conversation
@Donny9 I think it should be a nice idea to include a popen test to apps/testing/ostest. Testing only on Vela will be like "It works on my machine" TM! :-D |
apache/nuttx-apps#2163 contain the related change to make popen more conform the standard |
@xiaoxiang781216 actually it only created the popen() function. I'm talking about adding a popen() test into ostest |
@acassis OK, I will add popen test to ostest in another PR soon~, so we can merge this pr first, thanks~ |
@Donny9 please rebase the patch |
Done~ |
Because popen no longer needs to rely on intermediate tasks to start command tasks. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
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>
refs: https://man7.org/linux/man-pages/man2/dup.2.html Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
…r exec VELAPLATFO-18473 refs: https://man7.org/linux/man-pages/man2/fcntl.2.html If the FD_CLOEXEC bit is set, the file descriptor will automatically be closed during a successful execve(2). (If the execve(2) fails, the file descriptor is left open.) modify: 1. Ensure that the child task copies all fds of the parent task, including those with O_CLOEXE. 2. Make sure spawn_file_action is executed under fd with O_CLOEXEC, otherwise it will fail. 3. When a new task is activated or exec is called, close all fds with O_CLOEXEC flags. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Summary
sched/task: close file descriptor with O_CLOEXEC before active task or exec
modify:
including those with O_CLOEXE.
otherwise it will fail.
with O_CLOEXEC flags.
fs/dup3: impletement dup3/nx_dup3_from_tcb function
fs/dup/dup2: don't add O_CLOEXEC for new file descriptor
libs/lib_psfa_adddup2.c: remove workaround aboud dup2
Impact
posix_spawn/exec_module/task_create/... with exec or start new task
Testing
Vela