summaryrefslogtreecommitdiffstats
path: root/eglib/gmain.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-01-21 14:36:37 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-01-21 14:36:37 +0000
commitd125028230c2ea56b2015c8ae457449d75c583bc (patch)
tree9b7796bd3819561c2d5eb2ea5493a6d495d8d596 /eglib/gmain.c
parent7006ed3265196dfeb24ab2790dda6b817462cf48 (diff)
Further fixes to g_spawn_async
Diffstat (limited to 'eglib/gmain.c')
-rw-r--r--eglib/gmain.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/eglib/gmain.c b/eglib/gmain.c
index c3c2ec9b..8132d635 100644
--- a/eglib/gmain.c
+++ b/eglib/gmain.c
@@ -682,10 +682,22 @@ static void exec_child(const gchar *working_directory,
if (working_directory && chdir(working_directory) < 0)
_exit(EXIT_FAILURE);
+ if (!(flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN)) {
+ int open_max, fd, ret;
+
+ ret = 0;
+ open_max = sysconf(_SC_OPEN_MAX);
+ for (fd = 0; fd < open_max && ret == 0; fd++)
+ ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
+ }
+
null = open("/dev/null", O_RDWR);
- dup2(null, STDIN_FILENO);
- dup2(null, STDOUT_FILENO);
- dup2(null, STDERR_FILENO);
+ if (!(flags & G_SPAWN_CHILD_INHERITS_STDIN))
+ dup2(null, STDIN_FILENO);
+ if (flags & G_SPAWN_STDOUT_TO_DEV_NULL)
+ dup2(null, STDOUT_FILENO);
+ if (flags & G_SPAWN_STDERR_TO_DEV_NULL)
+ dup2(null, STDERR_FILENO);
if (null > 2)
close(null);