(dup2): Catch dup() failure. Return correct value.
authorRichard Kenner <kenner@gcc.gnu.org>
Thu, 10 Mar 1994 20:23:01 +0000 (15:23 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Thu, 10 Mar 1994 20:23:01 +0000 (15:23 -0500)
From-SVN: r6740

gcc/collect2.c

index 8256d87e246b66b49df18ca66c75e1b9d9616924..9f097a9ae4bdad6c6320ba06745ef093accea7e9 100644 (file)
@@ -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