aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-10-27 18:08:59 -0500
committerRob Landley <rob@landley.net>2014-10-27 18:08:59 -0500
commit45b3882a1187f0e957efbc4fc5d797ba9603f545 (patch)
tree37552d7877acf6ca5c803d7520026d262855fb21 /lib/lib.c
parentd4bae7ddb771d32d35cc953a3fedbcc622820dbe (diff)
downloadtoybox-45b3882a1187f0e957efbc4fc5d797ba9603f545.tar.gz
O_CLOEXEC was confusing the O_RDONLY test in loopfiles(), resulting in attempts to read from stdout instead of stdin for "-" or no arguments.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index dc2de121..5923176c 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -437,12 +437,12 @@ void loopfiles_rw(char **argv, int flags, int permissions, int failok,
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;