[glib] g_unix_open_pipe: Add missing F_SETFD
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_unix_open_pipe: Add missing F_SETFD
- Date: Wed, 12 Dec 2012 13:05:58 +0000 (UTC)
commit c70072180557c0a897da0d96ef2cf4f5398ddd3b
Author: Colin Walters <walters verbum org>
Date: Tue Dec 11 16:53:48 2012 -0500
g_unix_open_pipe: Add missing F_SETFD
Spotted by Ray Strode <rstrode redhat com>
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 files changed, 6 insertions(+), 2 deletions(-)
---
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]