From 65a7814b2dbc10ea86610092f03d0c1df95d08ad Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 23 May 2024 14:28:02 -0400 Subject: opt: Don't raise RLIMIT_NOFILE if it would prevent using posix_spawn() If we raise RLIMIT_NOFILE, we have to lower it before calling exec() for compatibility with select(). If posix_spawn() doesn't support that, we fall back to fork(), which is quite a bit slower. Therefore, if we're going to exec() on most files, it's better to keep RLIMIT_NOFILE the same to avoid the fork() cost, even though it makes bftw() somewhat slower. --- src/ctx.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ctx.h') diff --git a/src/ctx.h b/src/ctx.h index fc3020c..b28a63c 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -102,6 +102,8 @@ struct bfs_ctx { struct rlimit orig_nofile; /** The current RLIMIT_NOFILE limits. */ struct rlimit cur_nofile; + /** Whether the fd limit should be raised. */ + bool raise_nofile; /** The current time. */ struct timespec now; -- cgit v1.2.3