aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.c')
-rw-r--r--src/file.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/file.c b/src/file.c
index eb7135a..27709be 100644
--- a/src/file.c
+++ b/src/file.c
@@ -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");