changeset 1535:b50de98c9708

O_CLOEXEC was confusing the O_RDONLY test in loopfiles(), resulting in attempts to read from stdout instead of stdin for "-" or no arguments.
author Rob Landley <rob@landley.net>
date Mon, 27 Oct 2014 18:08:59 -0500
parents 83cac28515a3
children 1d996b0a11c0
files lib/lib.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.c	Sun Oct 26 13:34:33 2014 -0500
+++ b/lib/lib.c	Mon Oct 27 18:08:59 2014 -0500
@@ -437,12 +437,12 @@
   int fd;
 
   // If no arguments, read from stdin.
-  if (!*argv) function(flags ? 1 : 0, "-");
+  if (!*argv) function((flags & O_ACCMODE) != O_RDONLY ? 1 : 0, "-");
   else do {
     // Filename "-" means read from stdin.
     // Inability to open a file prints a warning, but doesn't exit.
 
-    if (!strcmp(*argv,"-")) fd=0;
+    if (!strcmp(*argv, "-")) fd=0;
     else if (0>(fd = open(*argv, flags, permissions)) && !failok) {
       perror_msg("%s", *argv);
       toys.exitval = 1;