Commit eadbc961 by Richard Kenner

(dup2): Catch dup() failure. Return correct value.

From-SVN: r6740
parent 4b19dee8
...@@ -277,14 +277,14 @@ dup2 (oldfd, newfd) ...@@ -277,14 +277,14 @@ dup2 (oldfd, newfd)
int fd; int fd;
if (oldfd == newfd) if (oldfd == newfd)
return 0; return oldfd;
close (newfd); close (newfd);
while ((fd = dup (oldfd)) != newfd) /* good enough for low fd's */ while ((fd = dup (oldfd)) != newfd && fd >= 0) /* good enough for low fd's */
fdtmp[fdx++] = fd; fdtmp[fdx++] = fd;
while (fdx > 0) while (fdx > 0)
close (fdtmp[--fdx]); close (fdtmp[--fdx]);
return 0; return fd;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment