From 16b3cb3fca46ccb5e3aee31adf936d6635777269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 15 Nov 2025 12:10:25 +0100 Subject: Work around copyFile leaving descriptor open in child processes --- src/FileUtils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/FileUtils.c (limited to 'src/FileUtils.c') 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 +#include +#include + +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 ); +} -- cgit v1.2.3