+2020-05-28 Bruno Haible <bruno@clisp.org>
+
+ copy-file: Make more robust in multithreaded applications.
+ * lib/copy-file.c (qcopy_file_preserving): Pass an O_CLOEXEC flag to
+ open().
+
2020-05-28 Bruno Haible <bruno@clisp.org>
chown: Make more robust in multithreaded applications.
int mode;
int dest_fd;
- src_fd = open (src_filename, O_RDONLY | O_BINARY);
+ src_fd = open (src_filename, O_RDONLY | O_BINARY | O_CLOEXEC);
if (src_fd < 0)
return GL_COPY_ERR_OPEN_READ;
if (fstat (src_fd, &statbuf) < 0)
off_t inbytes = S_ISREG (statbuf.st_mode) ? statbuf.st_size : -1;
bool empty_regular_file = inbytes == 0;
- dest_fd = open (dest_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600);
+ dest_fd = open (dest_filename,
+ O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC,
+ 0600);
if (dest_fd < 0)
{
err = GL_COPY_ERR_OPEN_BACKUP_WRITE;