diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-15 12:10:25 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-11-15 16:41:33 +0100 |
| commit | 16b3cb3fca46ccb5e3aee31adf936d6635777269 (patch) | |
| tree | 37d37374e17fbb6d5db074f5578a0e03fa6f3ecc /src/FileUtils.c | |
| parent | 3f6c94f897231b407e3c976e8d789d420ee5e6b7 (diff) | |
Work around copyFile leaving descriptor open in child processes
Diffstat (limited to 'src/FileUtils.c')
| -rw-r--r-- | src/FileUtils.c | 18 |
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 ); +} |