remap: *actually* build, and fix masked logic errors
[tftp-hpa.git] / lib / dup2.c
blobbba45c419dca9b103dd4e1536f60ad68122d9075
1 /*
2 * dup2.c
4 * Ersatz dup2() for really ancient systems
5 */
7 #include "config.h"
9 int dup2(int oldfd, int newfd)
11 int rv, nfd;
13 close(newfd);
15 nfd = rv = dup(oldfd);
17 if (rv >= 0 && rv != newfd) {
18 rv = dup2(oldfd, newfd);
19 close(nfd);
22 return rv;