mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
Use O_CLOEXEC in {g_,}open () calls for race-free setting of the close-on-exec flag
The remaining call sites are either Windows-only, between fork () and exec () or in xdgmime copylib. Hope I haven't missed any site.
This commit is contained in:
committed by
Philip Withnall
parent
0f5d274871
commit
3f2e18b07c
@@ -32,6 +32,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <glib/gfileutils.h>
|
||||
#include <gio/gfilemonitor.h>
|
||||
@@ -583,7 +587,7 @@ _kqsub_start_watching (kqueue_sub *sub)
|
||||
struct stat st;
|
||||
struct kevent ev;
|
||||
|
||||
sub->fd = open (sub->filename, O_KQFLAG);
|
||||
sub->fd = open (sub->filename, O_KQFLAG | O_CLOEXEC);
|
||||
if (sub->fd == -1)
|
||||
return FALSE;
|
||||
|
||||
|
Reference in New Issue
Block a user