9 __weak_alias(dup2
, _dup2
)
15 /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not
16 * quite the same as fcntl.
19 if (fd2
< 0 || fd2
> OPEN_MAX
) {
24 /* Check to see if fildes is valid. */
25 if (fcntl(fd
, F_GETFL
) < 0) {
26 /* 'fd' is not valid. */
30 if (fd
== fd2
) return(fd2
);
32 return(fcntl(fd
, F_DUPFD
, fd2
));