summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-05-06 23:36:32 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-05-06 23:36:32 -0400
commitc8c33b8c44751444729eda6a9fb7d4715928ea43 (patch)
treed2247b38683af70744f49f9fbe14cf707ea712c9 /main.c
parent72685e26e6cf5f19c840d8efaf54176ff12f7eca (diff)
downloadbfs-c8c33b8c44751444729eda6a9fb7d4715928ea43.tar.xz
main: Fix error checking of redirect()
Diffstat (limited to 'main.c')
-rw-r--r--main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.c b/main.c
index bcb0c11..0b957d3 100644
--- a/main.c
+++ b/main.c
@@ -23,8 +23,10 @@
static int ensure_fd_open(int fd, int flags) {
if (isopen(fd)) {
return 0;
+ } else if (redirect(fd, "/dev/null", flags) >= 0) {
+ return 0;
} else {
- return redirect(fd, "/dev/null", flags);
+ return -1;
}
}