mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
glocalfileoutputstream: Add a missing O_CLOEXEC flag to replace()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
87e19535fe
commit
ac505e88c4
@ -63,6 +63,12 @@
|
|||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_CLOEXEC
|
||||||
|
#define O_CLOEXEC 0
|
||||||
|
#else
|
||||||
|
#define HAVE_O_CLOEXEC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
struct _GLocalFileOutputStreamPrivate {
|
struct _GLocalFileOutputStreamPrivate {
|
||||||
char *tmp_filename;
|
char *tmp_filename;
|
||||||
char *original_filename;
|
char *original_filename;
|
||||||
@ -1239,7 +1245,7 @@ _g_local_file_output_stream_replace (const char *filename,
|
|||||||
sync_on_close = FALSE;
|
sync_on_close = FALSE;
|
||||||
|
|
||||||
/* If the file doesn't exist, create it */
|
/* If the file doesn't exist, create it */
|
||||||
open_flags = O_CREAT | O_EXCL | O_BINARY;
|
open_flags = O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC;
|
||||||
if (readable)
|
if (readable)
|
||||||
open_flags |= O_RDWR;
|
open_flags |= O_RDWR;
|
||||||
else
|
else
|
||||||
@ -1269,7 +1275,10 @@ _g_local_file_output_stream_replace (const char *filename,
|
|||||||
set_error_from_open_errno (filename, error);
|
set_error_from_open_errno (filename, error);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#if !defined(HAVE_O_CLOEXEC) && defined(F_SETFD)
|
||||||
|
else
|
||||||
|
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||||
|
#endif
|
||||||
|
|
||||||
stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
|
stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL);
|
||||||
stream->priv->fd = fd;
|
stream->priv->fd = fd;
|
||||||
|
Loading…
Reference in New Issue
Block a user