[misc] Fix macOS build (doesn't have SOCK_CLOEXEC)

This commit is contained in:
ejurgensen 2021-04-01 00:01:12 +02:00
parent ef95759782
commit ba8b752a9b
1 changed files with 8 additions and 0 deletions

View File

@ -205,7 +205,11 @@ net_connect(const char *addr, unsigned short port, int type, const char *log_ser
for (ptr = servinfo; ptr; ptr = ptr->ai_next)
{
#ifdef SOCK_CLOEXEC
fd = socket(ptr->ai_family, type | SOCK_CLOEXEC, ptr->ai_protocol);
#else
fd = socket(ptr->ai_family, type, ptr->ai_protocol);
#endif
if (fd < 0)
{
continue;
@ -269,7 +273,11 @@ net_bind(short unsigned *port, int type, const char *log_service_name)
if (fd >= 0)
close(fd);
#ifdef SOCK_CLOEXEC
fd = socket(ptr->ai_family, type | SOCK_CLOEXEC, ptr->ai_protocol);
#else
fd = socket(ptr->ai_family, type, ptr->ai_protocol);
#endif
if (fd < 0)
continue;