[glib] Bug 613601 - buglet in dup_close_on_exec_fd()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [glib] Bug 613601 - buglet in dup_close_on_exec_fd()
- Date: Tue, 23 Mar 2010 04:16:01 +0000 (UTC)
commit ace9a25fb39781a01a78c8e9aa1c58a51224e8b8
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Mar 22 11:59:08 2010 -0500
    Bug 613601 - buglet in dup_close_on_exec_fd()
    
    Fix copy/paste error and 'or' FD_CLOEXEC into the existing flags instead
    of just setting it outright.
 gio/gunixfdlist.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gio/gunixfdlist.c b/gio/gunixfdlist.c
index df715b2..026c127 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;
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]