Commit 9fe70c9e46fabae11ed7df8e9f97d3136802ba13

Andreas Smas 2017-01-20T23:14:19

Use SOCK_CLOEXEC when creating sockets

diff --git a/src/posix.h b/src/posix.h
index 3e3bcb2..2934f24 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -60,6 +60,9 @@
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 #endif
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
 
 /* access() mode parameter #defines	*/
 #ifndef F_OK
diff --git a/src/socket_stream.c b/src/socket_stream.c
index 4c795e4..3c2a07c 100644
--- a/src/socket_stream.c
+++ b/src/socket_stream.c
@@ -104,7 +104,7 @@ int socket_connect(git_stream *stream)
 	}
 
 	for (p = info; p != NULL; p = p->ai_next) {
-		s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
+		s = socket(p->ai_family, p->ai_socktype | SOCK_CLOEXEC, p->ai_protocol);
 
 		if (s == INVALID_SOCKET)
 			continue;