[glib] g_unix_open_pipe: fix some bugs



commit 15a1cf804974c3fa526bab8a6b80eb27518313f3
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jul 25 15:25:13 2011 +0200

    g_unix_open_pipe: fix some bugs
    
    Fix some bugs in the fallback case of g_unix_open_pipe:
    
      - close both halves of the pipe on error (not just one)
    
      - set the cloexec flag on both halves of the pipe (instead of settings
        it twice on one half)

 glib/glib-unix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index 732e5fc..77bcea1 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -113,9 +113,10 @@ g_unix_open_pipe (int     *fds,
     {
       int saved_errno = errno;
       close (fds[0]);
+      close (fds[1]);
       return g_unix_set_error_from_errno (error, saved_errno);
     }
-  ecode = fcntl (fds[0], flags);
+  ecode = fcntl (fds[1], flags);
   if (ecode == -1)
     {
       int saved_errno = errno;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]