--- a/router/src/harness/include/mysql/harness/net_ts/impl/file.h 2025-09-24 21:35:03.000000000 +0800 +++ b/router/src/harness/include/mysql/harness/net_ts/impl/file.h 2025-12-15 00:03:50.000000000 +0800 @@ -96,7 +96,32 @@ // posix using dup_fd = file_control_option; +#ifndef F_DUPFD_CLOEXEC +namespace { +class DupFdCloexec { + public: + static constexpr int value = F_DUPFD; + + static int apply(int fd, int min_fd) { + int new_fd = :: fcntl(fd, F_DUPFD, min_fd); + if (new_fd != -1) { + int flags = ::fcntl(new_fd, F_GETFD); + if (flags != -1) { + ::fcntl(new_fd, F_SETFD, flags | FD_CLOEXEC); + } else { + ::close(new_fd); + return -1; + } + } + return new_fd; + } +}; +} // namespace + +using dup_fd_cloexec = file_control_option; +#else using dup_fd_cloexec = file_control_option; +#endif // posix //