summaryrefslogtreecommitdiff
path: root/src/FileUtils.c
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-11-15 12:10:25 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2025-11-15 16:41:33 +0100
commit16b3cb3fca46ccb5e3aee31adf936d6635777269 (patch)
tree37d37374e17fbb6d5db074f5578a0e03fa6f3ecc /src/FileUtils.c
parent3f6c94f897231b407e3c976e8d789d420ee5e6b7 (diff)
Work around copyFile leaving descriptor open in child processes
Diffstat (limited to 'src/FileUtils.c')
-rw-r--r--src/FileUtils.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/FileUtils.c b/src/FileUtils.c
new file mode 100644
index 0000000..3cf2997
--- /dev/null
+++ b/src/FileUtils.c
@@ -0,0 +1,18 @@
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+int minici_fd_open_read( const char * from )
+{
+ return open( from, O_RDONLY | O_CLOEXEC );
+}
+
+int minici_fd_create_write( const char * from, int fd_perms )
+{
+ struct stat st;
+ mode_t mode = 0600;
+ if( fstat( fd_perms, & st ) == 0 )
+ mode = st.st_mode;
+
+ return open( from, O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, mode );
+}