]> Savannah Git Hosting - gnulib.git/commitdiff
posix_spawn-internal: Don't lose flags while duplicating an fd.
authorBruno Haible <bruno@clisp.org>
Sat, 10 Sep 2022 00:26:18 +0000 (02:26 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 10 Sep 2022 01:03:35 +0000 (03:03 +0200)
* lib/spawni.c (do_dup2): Fix the flags of the new fd.

ChangeLog
lib/spawni.c

index 7c237a1e66965e4dc9432d611cc1f09f8c6d9f57..564facbe53fc28eda1f7b13ea3966e6fd4f9ea7e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-09-09  Bruno Haible  <bruno@clisp.org>
+
+       posix_spawn-internal: Don't lose flags while duplicating an fd.
+       * lib/spawni.c (do_dup2): Fix the flags of the new fd.
+
 2022-09-09  Bruno Haible  <bruno@clisp.org>
 
        spawn-pipe: Fix pipe-filter-* test hangs (regression 2020-12-24).
index 8125ce19ee26b998a2e6f20a67831f5dea1d237d..b9b0589460a5190ca28f80dd9e9eabf3ace38831 100644 (file)
@@ -471,7 +471,8 @@ do_dup2 (struct inheritable_handles *inh_handles, int oldfd, int newfd,
           errno = EBADF; /* arbitrary */
           return -1;
         }
-      inh_handles->flags[newfd] = KEEP_OPEN_IN_CHILD;
+      inh_handles->flags[newfd] =
+        (unsigned char) inh_handles->flags[oldfd] | KEEP_OPEN_IN_CHILD;
     }
   return 0;
 }