From c70072180557c0a897da0d96ef2cf4f5398ddd3b Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 11 Dec 2012 16:53:48 -0500 Subject: [PATCH] g_unix_open_pipe: Add missing F_SETFD Spotted by Ray Strode While we're here, microoptimize by skipping the fcntl() calls if flags is 0. https://bugzilla.gnome.org/show_bug.cgi?id=690069 --- glib/glib-unix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glib/glib-unix.c b/glib/glib-unix.c index 9e87bb5de..9cc27169a 100644 --- a/glib/glib-unix.c +++ b/glib/glib-unix.c @@ -105,7 +105,11 @@ g_unix_open_pipe (int *fds, ecode = pipe (fds); if (ecode == -1) return g_unix_set_error_from_errno (error, errno); - ecode = fcntl (fds[0], flags); + + if (flags == 0) + return TRUE; + + ecode = fcntl (fds[0], F_SETFD, flags); if (ecode == -1) { int saved_errno = errno; @@ -113,7 +117,7 @@ g_unix_open_pipe (int *fds, close (fds[1]); return g_unix_set_error_from_errno (error, saved_errno); } - ecode = fcntl (fds[1], flags); + ecode = fcntl (fds[1], F_SETFD, flags); if (ecode == -1) { int saved_errno = errno; -- 2.34.1