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
This commit is contained in:
Colin Walters 2012-12-11 16:53:48 -05:00
parent 5baa26be72
commit c700721805

View File

@ -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;