OSDN Git Service

Don't close stdin when loopfiles reads "-".
authorRob Landley <rob@landley.net>
Fri, 15 Jul 2016 09:39:35 +0000 (04:39 -0500)
committerRob Landley <rob@landley.net>
Fri, 15 Jul 2016 09:39:35 +0000 (04:39 -0500)
lib/lib.c

index 3f4819f..09264c9 100644 (file)
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -570,7 +570,7 @@ void loopfiles_rw(char **argv, int flags, int permissions, int failok,
       continue;
     }
     function(fd, *argv);
-    if (flags & O_CLOEXEC) close(fd);
+    if ((flags & O_CLOEXEC) && fd) close(fd);
   } while (*++argv);
 }