>From 31eae47a8c3b645d8e096541ad0e8906b9490e16 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 10 Sep 2022 02:26:18 +0200 Subject: [PATCH 1/5] posix_spawn-internal: Don't lose flags while duplicating an fd. * lib/spawni.c (do_dup2): Fix the flags of the new fd. --- ChangeLog | 5 +++++ lib/spawni.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 44d486f212..3b4db6dfff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-09-09 Bruno Haible + + 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 spawn-pipe: Fix pipe-filter-* test hangs (regression 2020-12-24). diff --git a/lib/spawni.c b/lib/spawni.c index 8125ce19ee..b9b0589460 100644 --- a/lib/spawni.c +++ b/lib/spawni.c @@ -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; } -- 2.34.1