diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-11-03 23:07:27 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-11-03 23:07:27 +0100 |
commit | c77fd48024d6de425e890f74cc11142085e4b5b8 (patch) | |
tree | 11af154c265da33514a07c7f81427be290676a8d /xe.c | |
parent | 8c499789196b79a8e681b22e19065d37eb76a309 (diff) | |
download | xe-c77fd48024d6de425e890f74cc11142085e4b5b8.tar.gz xe-c77fd48024d6de425e890f74cc11142085e4b5b8.tar.xz xe-c77fd48024d6de425e890f74cc11142085e4b5b8.zip |
run: close fd 0 if dup'ing /dev/null fails
Diffstat (limited to 'xe.c')
-rw-r--r-- | xe.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/xe.c b/xe.c index 4cc416c..018ee3b 100644 --- a/xe.c +++ b/xe.c @@ -233,12 +233,15 @@ run() snprintf(iter, sizeof iter, "%ld", iterations); setenv("ITER", iter, 1); // redirect stdin to /dev/null when we read arguments from it + // just close it if this fails if (input == stdin) { int fd = open("/dev/null", O_RDONLY); if (fd >= 0) { if (dup2(fd, 0) != 0) - exit(1); + close(0); close(fd); + } else { + close(0); } } |