summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-09-09 12:18:41 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-09-09 12:18:41 -0400
commitec92ae82f381169be0223e37f5afd85f0c6d2f21 (patch)
tree4d0604fbb09690a657672d981b479a1a52c2c52a
parent836fbdf183bca11d3a68eee890978fd7c7fd5dab (diff)
downloadbfs-ec92ae82f381169be0223e37f5afd85f0c6d2f21.tar.xz
eval: Make sure nopenfd >= 2 for bftw()
-rw-r--r--eval.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/eval.c b/eval.c
index 6c25e18..340e9eb 100644
--- a/eval.c
+++ b/eval.c
@@ -1170,13 +1170,12 @@ static int infer_fdlimit(const struct cmdline *cmdline) {
closedir(dir);
}
- // Extra fd needed by -empty
- int reserved = nopen + 1;
+ // 1 extra fd needed by -empty
+ ret -= nopen + 1;
- if (ret > reserved) {
- ret -= reserved;
- } else {
- ret = 1;
+ // bftw() needs at least 2 available fds
+ if (ret < 2) {
+ ret = 2;
}
return ret;