summaryrefslogtreecommitdiffstats
path: root/src/ctx.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-23 14:28:02 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-23 14:34:33 -0400
commit65a7814b2dbc10ea86610092f03d0c1df95d08ad (patch)
tree3075cb84811b6be8dba357f96dcbbf955905b2e3 /src/ctx.c
parent07b0c50e94543a88f699fa60b577d8e53c978ff1 (diff)
downloadbfs-65a7814b2dbc10ea86610092f03d0c1df95d08ad.tar.xz
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.
Diffstat (limited to 'src/ctx.c')
-rw-r--r--src/ctx.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/ctx.c b/src/ctx.c
index 71fef98..fac501a 100644
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -56,6 +56,7 @@ struct bfs_ctx *bfs_ctx_new(void) {
goto fail;
}
ctx->cur_nofile = ctx->orig_nofile;
+ ctx->raise_nofile = true;
ctx->users = bfs_users_new();
if (!ctx->users) {