This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit e61ff51e6755b88618641e5fa850184b11c16ebd
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Tue Oct 24 13:40:07 2023 +0800

    system/popen: remove O_CLOEXEC if mode exinclude 'e'
    
    refs: https://man7.org/linux/man-pages/man3/popen.3.html
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 system/popen/popen.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/system/popen/popen.c b/system/popen/popen.c
index 05abcd20d..254f86ae6 100644
--- a/system/popen/popen.c
+++ b/system/popen/popen.c
@@ -320,6 +320,11 @@ FILE *popen(FAR const char *command, FAR const char *mode)
   posix_spawn_file_actions_destroy(&file_actions);
   posix_spawnattr_destroy(&attr);
 
+  if (strchr(mode, 'e') == NULL)
+    {
+      fcntl(retfd, F_SETFD, 0);
+    }
+
   /* Finale and return input input/output stream */
 
   memcpy(&container->copy, container->original, sizeof(FILE));

Reply via email to