aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/lib.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 7af2af11..ec491063 100644
--- 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;
}