diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-23 21:53:58 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-23 21:53:58 +0200 |
commit | 1e35db47ccefa8371fdc6d70d8895df19d8a1b98 (patch) | |
tree | 13485f4144847002d58512773fd73a195e2e33ea | |
parent | net: fix recv_all (diff) | |
download | cimple-1e35db47ccefa8371fdc6d70d8895df19d8a1b98.tar.gz cimple-1e35db47ccefa8371fdc6d70d8895df19d8a1b98.zip |
net: use CLOEXEC
I've only recently learned about this flag, seems generally useful.
Diffstat (limited to '')
-rw-r--r-- | src/net.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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; |