O_CLOEXEC was confusing the O_RDONLY test in loopfiles(), resulting in attempts to read from stdout instead of stdin for "-" or no arguments.
diff --git a/lib/lib.c b/lib/lib.c
index dc2de12..5923176 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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;