Skip to content

Commit 9fe70c9

Browse files
committed
Use SOCK_CLOEXEC when creating sockets
1 parent c7c5f2c commit 9fe70c9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/posix.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
#ifndef O_CLOEXEC
6161
#define O_CLOEXEC 0
6262
#endif
63+
#ifndef SOCK_CLOEXEC
64+
#define SOCK_CLOEXEC 0
65+
#endif
6366

6467
/* access() mode parameter #defines */
6568
#ifndef F_OK

src/socket_stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int socket_connect(git_stream *stream)
104104
}
105105

106106
for (p = info; p != NULL; p = p->ai_next) {
107-
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
107+
s = socket(p->ai_family, p->ai_socktype | SOCK_CLOEXEC, p->ai_protocol);
108108

109109
if (s == INVALID_SOCKET)
110110
continue;

0 commit comments

Comments
 (0)