64 lines
1.4 KiB
Diff
64 lines
1.4 KiB
Diff
From ba5305d42a210a07e9f6a18284dc0c07d5e45c14 Mon Sep 17 00:00:00 2001
|
|
From: Martell Malone <martellmalone@gmail.com>
|
|
Date: Fri, 26 Jun 2015 00:02:23 +0100
|
|
Subject: [PATCH 7/8] cloexec hackery for windows
|
|
|
|
---
|
|
deps/cloexec/cloexec.c | 7 +++++++
|
|
deps/cloexec/cloexec.h | 6 +++++-
|
|
2 files changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/deps/cloexec/cloexec.c b/deps/cloexec/cloexec.c
|
|
index 1442526..b9051fc 100644
|
|
--- a/deps/cloexec/cloexec.c
|
|
+++ b/deps/cloexec/cloexec.c
|
|
@@ -26,7 +26,12 @@ pthread_mutex_t cloexec_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
static int set_cloexec(int fd)
|
|
{
|
|
+#ifdef _WIN32
|
|
+ u_long nonblock = 1;
|
|
+ return ioctlsocket(fd, FIONBIO, &nonblock) != -1 ? 0 : -1;
|
|
+#else
|
|
return fcntl(fd, F_SETFD, FD_CLOEXEC) != -1 ? 0 : -1;
|
|
+#endif
|
|
}
|
|
|
|
int cloexec_accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
|
|
@@ -51,6 +56,7 @@ Exit:
|
|
#endif
|
|
}
|
|
|
|
+#ifndef _WIN32
|
|
int cloexec_pipe(int fds[2])
|
|
{
|
|
#ifdef __linux__
|
|
@@ -70,6 +76,7 @@ Exit:
|
|
return ret;
|
|
#endif
|
|
}
|
|
+#endif
|
|
|
|
int cloexec_socket(int domain, int type, int protocol)
|
|
{
|
|
diff --git a/deps/cloexec/cloexec.h b/deps/cloexec/cloexec.h
|
|
index 53987ed..1ea9155 100644
|
|
--- a/deps/cloexec/cloexec.h
|
|
+++ b/deps/cloexec/cloexec.h
|
|
@@ -23,7 +23,11 @@
|
|
#define CLOEXEC_H
|
|
|
|
#include <pthread.h>
|
|
-#include <sys/socket.h>
|
|
+#ifdef _WIN32
|
|
+# include <ws2tcpip.h>
|
|
+#else
|
|
+# include <sys/socket.h>
|
|
+#endif
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
--
|
|
2.4.4
|
|
|