summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gio/gunixfdlist.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gio/gunixfdlist.c b/gio/gunixfdlist.c
index df715b21a..026c1276e 100644
--- a/gio/gunixfdlist.c
+++ b/gio/gunixfdlist.c
@@ -117,10 +117,15 @@ dup_close_on_exec_fd (gint fd,
}
do
- s = fcntl (new_fd, F_SETFD, FD_CLOEXEC);
+ {
+ s = fcntl (new_fd, F_GETFD);
+
+ if (s >= 0)
+ s = fcntl (new_fd, F_SETFD, (long) (s | FD_CLOEXEC));
+ }
while (s < 0 && (errno == EINTR));
- if (new_fd < 0)
+ if (s < 0)
{
int saved_errno = errno;