aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/net.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net.c b/src/net.c
index b40cba8..e41d5ea 100644
--- a/src/net.c
+++ b/src/net.c
@@ -50,7 +50,7 @@ int bind_to_port(const char *port)
}
for (it = result; it; it = it->ai_next) {
- socket_fd = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
+ socket_fd = socket(it->ai_family, it->ai_socktype | SOCK_CLOEXEC, it->ai_protocol);
if (socket_fd < 0) {
print_errno("socket");
continue;
@@ -105,7 +105,7 @@ int accept_connection(int fd, connection_handler handler, void *arg)
{
int conn_fd, ret = 0;
- ret = accept(fd, NULL, NULL);
+ ret = accept4(fd, NULL, NULL, SOCK_CLOEXEC);
if (ret < 0) {
print_errno("accept");
return ret;
@@ -149,7 +149,7 @@ int connect_to_host(const char *host, const char *port)
}
for (it = result; it; it = it->ai_next) {
- socket_fd = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
+ socket_fd = socket(it->ai_family, it->ai_socktype | SOCK_CLOEXEC, it->ai_protocol);
if (socket_fd < 0) {
print_errno("socket");
continue;