diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-04 16:43:52 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-04 16:47:08 +0200 |
commit | 4a0b974b85f36011fb1a8c17bf59bc272d96a522 (patch) | |
tree | fc05115a4e0f1b37cfd1733acdf1981c3005ae03 /src/file.c | |
parent | sqlite: store new runs in SQLite (diff) | |
download | cimple-4a0b974b85f36011fb1a8c17bf59bc272d96a522.tar.gz cimple-4a0b974b85f36011fb1a8c17bf59bc272d96a522.zip |
tcp_server: always clean up connection descriptors
Diffstat (limited to '')
-rw-r--r-- | src/file.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -9,6 +9,7 @@ #include "compiler.h" #include "log.h" +#include <fcntl.h> #include <ftw.h> #include <stdio.h> #include <stdlib.h> @@ -98,6 +99,19 @@ free: return NULL; } +int file_dup(int fd) +{ + int ret = 0; + + ret = fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (ret < 0) { + log_errno("fcntl"); + return ret; + } + + return ret; +} + void file_close(int fd) { log_errno_if(close(fd), "close"); |