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>
Message-Id: <
20230429131354.
2507443-6-bugaevc@gmail.com>
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;