aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-04-30 14:12:21 +0200
committerMattias Andrée <maandree@kth.se>2017-04-30 14:12:21 +0200
commit8c5fcaffb6461ef5706f3dc90653f11eb0065734 (patch)
tree2e8d92abf6849f02bdae527efbcf8eb4e6a6df46 /src
parentDo not reopen /dev/std{in,out,err} when specified explicitly (diff)
downloadblind-8c5fcaffb6461ef5706f3dc90653f11eb0065734.tar.gz
blind-8c5fcaffb6461ef5706f3dc90653f11eb0065734.tar.bz2
blind-8c5fcaffb6461ef5706f3dc90653f11eb0065734.tar.xz
Use stdin or stdout (depending on access mode) when opening -
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
-rw-r--r--src/util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 95b46f4..a30f0f0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -243,6 +243,11 @@ xenopen(int status, const char *path, int flags, int mode, ...)
return STDOUT_FILENO;
} else if (!strcmp(path, "/dev/stderr")) {
return STDERR_FILENO;
+ } else if (!strcmp(path, "-")) {
+ if ((flags & O_ACCMODE) == O_RDONLY)
+ return STDIN_FILENO;
+ else
+ return STDOUT_FILENO;
}
fd = open(path, flags, mode);
if (fd < 0)