Feeding -1 to xdup() isn't an error.
authorRob Landley <rob@landley.net>
Sun, 10 Jun 2012 00:49:37 +0000 (19:49 -0500)
committerRob Landley <rob@landley.net>
Sun, 10 Jun 2012 00:49:37 +0000 (19:49 -0500)
lib/lib.c

index 7af2af1..ec49106 100644 (file)
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -210,8 +210,10 @@ void xclose(int fd)
 
 int xdup(int fd)
 {
-       fd = dup(fd);
-       if (fd == -1) perror_exit("xdup");
+       if (fd != -1) {
+               fd = dup(fd);
+               if (fd == -1) perror_exit("xdup");
+       }
        return fd;
 }