8 PUBLIC
int dup2(fd
, fd2
)
11 /* The behavior of dup2 is defined by POSIX in 6.2.1.2 as almost, but not
12 * quite the same as fcntl.
15 if (fd2
< 0 || fd2
> OPEN_MAX
) {
20 /* Check to see if fildes is valid. */
21 if (fcntl(fd
, F_GETFL
) < 0) {
22 /* 'fd' is not valid. */
26 if (fd
== fd2
) return(fd2
);
28 return(fcntl(fd
, F_DUPFD
, fd2
));