From: Sergey Bugaev <bugaevc@gmail.com>
To: libc-alpha@sourceware.org
Cc: bug-hurd@gnu.org, Samuel Thibault <samuel.thibault@gnu.org>
Subject: [PATCH 6/7] hurd: Respect existing FD_CLOEXEC in S_msg_set_fd
Date: Sat, 29 Apr 2023 16:13:53 +0300 [thread overview]
Message-ID: <20230429131354.2507443-6-bugaevc@gmail.com> (raw)
In-Reply-To: <20230429131354.2507443-1-bugaevc@gmail.com>
If the process has set the close-on-exec flag for the file descriptor,
it expects the file descriptor to get closed on exec, even if we replace
what the file descriptor refers to.
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
hurd/hurdmsg.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hurd/hurdmsg.c b/hurd/hurdmsg.c
index 896fb87c..8fde1f53 100644
--- a/hurd/hurdmsg.c
+++ b/hurd/hurdmsg.c
@@ -323,7 +323,13 @@ _S_msg_set_fd (mach_port_t msgport, mach_port_t auth,
AUTHCHECK;
/* We consume the reference if successful. */
- err = HURD_FD_USE (which, (_hurd_port2fd (descriptor, port, 0), 0));
+ err = HURD_FD_USE (which,
+ ({
+ int flags = (descriptor->flags & FD_CLOEXEC)
+ ? O_CLOEXEC : 0;
+ _hurd_port2fd (descriptor, port, flags);
+ 0;
+ }));
if (err)
return err;
--
2.40.1
next prev parent reply other threads:[~2023-04-29 13:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-29 13:13 [PATCH 1/7] hurd: Simplify _hurd_critical_section_lock a bit Sergey Bugaev
2023-04-29 13:13 ` [PATCH 2/7] hurd: Move libc_hidden_def's around Sergey Bugaev
2023-04-29 14:52 ` Samuel Thibault
2023-04-29 13:13 ` [PATCH 3/7] hurd: Mark various conditions as unlikely Sergey Bugaev
2023-04-29 14:53 ` Samuel Thibault
2023-04-29 13:13 ` [PATCH 4/7] hurd: Make _exit work during early boot-up Sergey Bugaev
2023-04-29 14:54 ` Samuel Thibault
2023-04-29 13:13 ` [PATCH 5/7] hurd: Don't leak the auth port in msg* RPCs Sergey Bugaev
2023-04-29 14:56 ` Samuel Thibault
2023-04-29 13:13 ` Sergey Bugaev [this message]
2023-04-29 14:57 ` [PATCH 6/7] hurd: Respect existing FD_CLOEXEC in S_msg_set_fd Samuel Thibault
2023-04-29 13:13 ` [PATCH 7/7] hurd: Fix FS_RETRY_MAGICAL "machtype" handling Sergey Bugaev
2023-04-29 15:01 ` Samuel Thibault
2023-04-29 14:50 ` [PATCH 1/7] hurd: Simplify _hurd_critical_section_lock a bit Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230429131354.2507443-6-bugaevc@gmail.com \
--to=bugaevc@gmail.com \
--cc=bug-hurd@gnu.org \
--cc=libc-alpha@sourceware.org \
--cc=samuel.thibault@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).