aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-04-30 14:00:19 +0200
committerMattias Andrée <maandree@kth.se>2017-04-30 14:00:19 +0200
commit77edf68c1a986fa3f80f5d5c986a736cbb5d24c4 (patch)
treed852ba2081c040bd16d22c1c67a6aac0bb137c5f /src/util.c
parentClean up (diff)
downloadblind-77edf68c1a986fa3f80f5d5c986a736cbb5d24c4.tar.gz
blind-77edf68c1a986fa3f80f5d5c986a736cbb5d24c4.tar.bz2
blind-77edf68c1a986fa3f80f5d5c986a736cbb5d24c4.tar.xz
Do not reopen /dev/std{in,out,err} when specified explicitly
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index b5aac6e..95b46f4 100644
--- a/src/util.c
+++ b/src/util.c
@@ -234,9 +234,16 @@ int
xenopen(int status, const char *path, int flags, int mode, ...)
{
int fd;
- if (!strncmp(path, "/dev/fd/", sizeof("/dev/fd/") - 1))
+ if (!strncmp(path, "/dev/fd/", sizeof("/dev/fd/") - 1)) {
if (!toi(path + sizeof("/dev/fd/") - 1, 0, INT_MAX, &fd))
return fd;
+ } else if (!strcmp(path, "/dev/stdin")) {
+ return STDIN_FILENO;
+ } else if (!strcmp(path, "/dev/stdout")) {
+ return STDOUT_FILENO;
+ } else if (!strcmp(path, "/dev/stderr")) {
+ return STDERR_FILENO;
+ }
fd = open(path, flags, mode);
if (fd < 0)
enprintf(status, "open %s:", path);