dup2 ¶POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/dup2.html
Portability problems fixed by Gnulib:
<io.h>)
on some platforms:
MSVC 14.
EINVAL when duplicating an fd to itself:
Android.
FD_CLOEXEC flag when duplicating an fd
to itself on some platforms:
Haiku.
dup2 (1, 1) on some platforms:
Cygwin 1.5.x.
-EBADF instead of -1 on some platforms:
Linux releases between July 2008 and May 2009 (versions 2.6.27 to 2.6.29).
EMFILE instead of EBADF for
large targets, which interferes with using
dup2(fd,fd)==fd) as the minimal EBADF filter:
AIX 7.1, FreeBSD 6.1, Cygwin 1.5.
Portability problems not fixed by Gnulib: