From: Colin Walters Date: Tue, 11 Dec 2012 21:53:48 +0000 (-0500) Subject: g_unix_open_pipe: Add missing F_SETFD X-Git-Tag: 2.35.3~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c70072180557c0a897da0d96ef2cf4f5398ddd3b;p=platform%2Fupstream%2Fglib.git 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 --- diff --git a/glib/glib-unix.c b/glib/glib-unix.c index 9e87bb5..9cc2716 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;