#ifdef __linux__
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/types.h>
extern "C"
{
int __real_socket(int domain, int type, int protocol) noexcept;
int __wrap_socket(int domain, int type, int protocol) noexcept
{
return __real_socket(domain, type | SOCK_CLOEXEC, protocol);
}
int __wrap_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
return accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
}
int __real_open(const char *pathname, int flags, mode_t mode);
int __wrap_open(const char *pathname, int flags, mode_t mode)
{
return __real_open(pathname, flags | O_CLOEXEC, mode);
}
}
#endif