Red Hat Bugzilla – Bug 864371
3.7.0 kernel dup3 (fd, fd) doesn't fail
Last modified: 2016-04-26 09:29:19 EDT
Description of problem:
A second problem we noticed from the gnulib test is that this
assertion fails with the latest upstream kernel:
/* Assigning to self is invalid. */
errno = 0;
ASSERT (dup3 (fd, fd, o_flags) == -1); <--- fails
ASSERT (errno == EINVAL);
dup3 is not currently specified by POSIX, so technically it is fine
for dup3 on Linux to do anything it likes.
*However* the proposal for dup3 in POSIX:
"The dup3( ) function shall be equivalent to the dup2( ) function if
the flag argument is 0, except that it shall be an error if fildes
is equal to fildes2."
So it's probably a good idea for Linux not to regress here.
(Thanks Jim Meyering for finding the link)
Version-Release number of selected component (if applicable):
Upstream bug report:
Created attachment 624011 [details]
dup3.c (test case)
$ gcc /tmp/dup3.c -o /tmp/dup3
dup3 (fd, fd, 0) didn't fail!
This patch was apparently accepted upstream: