mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-30 04:13:06 +02:00
gspawn: Use fcntl() to work around systems which don’t support O_CLOEXEC
Somehow, we are still limping along with partial support for OS X <10.7. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/glib/issues/1488
This commit is contained in:
parent
cce309aebb
commit
4afe429d7c
@ -81,6 +81,12 @@
|
|||||||
extern char **environ;
|
extern char **environ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_CLOEXEC
|
||||||
|
#define O_CLOEXEC 0
|
||||||
|
#else
|
||||||
|
#define HAVE_O_CLOEXEC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:spawn
|
* SECTION:spawn
|
||||||
* @Short_description: process launching
|
* @Short_description: process launching
|
||||||
@ -1454,6 +1460,10 @@ do_posix_spawn (gchar **argv,
|
|||||||
g_assert (read_null != -1);
|
g_assert (read_null != -1);
|
||||||
parent_close_fds[num_parent_close_fds++] = read_null;
|
parent_close_fds[num_parent_close_fds++] = read_null;
|
||||||
|
|
||||||
|
#ifndef HAVE_O_CLOEXEC
|
||||||
|
fcntl (read_null, F_SETFD, FD_CLOEXEC);
|
||||||
|
#endif
|
||||||
|
|
||||||
r = posix_spawn_file_actions_adddup2 (&file_actions, read_null, 0);
|
r = posix_spawn_file_actions_adddup2 (&file_actions, read_null, 0);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
goto out_close_fds;
|
goto out_close_fds;
|
||||||
@ -1474,6 +1484,10 @@ do_posix_spawn (gchar **argv,
|
|||||||
g_assert (write_null != -1);
|
g_assert (write_null != -1);
|
||||||
parent_close_fds[num_parent_close_fds++] = write_null;
|
parent_close_fds[num_parent_close_fds++] = write_null;
|
||||||
|
|
||||||
|
#ifndef HAVE_O_CLOEXEC
|
||||||
|
fcntl (read_null, F_SETFD, FD_CLOEXEC);
|
||||||
|
#endif
|
||||||
|
|
||||||
r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 1);
|
r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 1);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
goto out_close_fds;
|
goto out_close_fds;
|
||||||
@ -1494,6 +1508,10 @@ do_posix_spawn (gchar **argv,
|
|||||||
g_assert (write_null != -1);
|
g_assert (write_null != -1);
|
||||||
parent_close_fds[num_parent_close_fds++] = write_null;
|
parent_close_fds[num_parent_close_fds++] = write_null;
|
||||||
|
|
||||||
|
#ifndef HAVE_O_CLOEXEC
|
||||||
|
fcntl (read_null, F_SETFD, FD_CLOEXEC);
|
||||||
|
#endif
|
||||||
|
|
||||||
r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 2);
|
r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 2);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
goto out_close_fds;
|
goto out_close_fds;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user