diff options
Diffstat (limited to 'src/file.c')
-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"); |