From: Richard Kenner Date: Thu, 10 Mar 1994 20:23:01 +0000 (-0500) Subject: (dup2): Catch dup() failure. Return correct value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eadbc96110328dd5ccab01c9e4dfb478aa0a1c6b;p=gcc.git (dup2): Catch dup() failure. Return correct value. From-SVN: r6740 --- diff --git a/gcc/collect2.c b/gcc/collect2.c index 8256d87e246..9f097a9ae4b 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -277,14 +277,14 @@ dup2 (oldfd, newfd) int fd; if (oldfd == newfd) - return 0; + return oldfd; 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; while (fdx > 0) close (fdtmp[--fdx]); - return 0; + return fd; } #endif