mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 14:06:15 +01:00
Revert "Handling collision between standard i/o file descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.
This reverts commit d9ba615090
Closes: #2795
Reopens: #16
This commit is contained in:
parent
05fdb2d049
commit
2a36bb4b7e
@ -108,17 +108,6 @@ g_unix_open_pipe (int *fds,
|
|||||||
ecode = pipe2 (fds, pipe2_flags);
|
ecode = pipe2 (fds, pipe2_flags);
|
||||||
if (ecode == -1 && errno != ENOSYS)
|
if (ecode == -1 && errno != ENOSYS)
|
||||||
return g_unix_set_error_from_errno (error, errno);
|
return g_unix_set_error_from_errno (error, errno);
|
||||||
/* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
|
|
||||||
else if (fds[0] < 3 || fds[1] < 3)
|
|
||||||
{
|
|
||||||
int old_fds[2] = { fds[0], fds[1] };
|
|
||||||
gboolean result = g_unix_open_pipe (fds, flags, error);
|
|
||||||
close (old_fds[0]);
|
|
||||||
close (old_fds[1]);
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
g_unix_set_error_from_errno (error, errno);
|
|
||||||
}
|
|
||||||
else if (ecode == 0)
|
else if (ecode == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
/* Fall through on -ENOSYS, we must be running on an old kernel */
|
/* Fall through on -ENOSYS, we must be running on an old kernel */
|
||||||
@ -127,19 +116,6 @@ g_unix_open_pipe (int *fds,
|
|||||||
ecode = pipe (fds);
|
ecode = pipe (fds);
|
||||||
if (ecode == -1)
|
if (ecode == -1)
|
||||||
return g_unix_set_error_from_errno (error, errno);
|
return g_unix_set_error_from_errno (error, errno);
|
||||||
/* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
|
|
||||||
else if (fds[0] < 3 || fds[1] < 3)
|
|
||||||
{
|
|
||||||
int old_fds[2] = { fds[0], fds[1] };
|
|
||||||
gboolean result = g_unix_open_pipe (fds, flags, error);
|
|
||||||
close (old_fds[0]);
|
|
||||||
close (old_fds[1]);
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
g_unix_set_error_from_errno (error, errno);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags == 0)
|
if (flags == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user