From ec92ae82f381169be0223e37f5afd85f0c6d2f21 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 9 Sep 2017 12:18:41 -0400 Subject: eval: Make sure nopenfd >= 2 for bftw() --- eval.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'eval.c') 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; -- cgit v1.2.3