core: if we change RLIMIT_NOFILE, reset it when executing commands

This commit is contained in:
Jeffrey C. Ollie
2025-01-01 14:31:15 -06:00
parent 60611b8a4a
commit 9ea0aa4934
4 changed files with 32 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ const Command = @This();
const std = @import("std");
const builtin = @import("builtin");
const global_state = &@import("global.zig").state;
const internal_os = @import("os/main.zig");
const windows = internal_os.windows;
const TempDir = internal_os.TempDir;
@@ -178,6 +179,10 @@ fn startPosix(self: *Command, arena: Allocator) !void {
// If the user requested a pre exec callback, call it now.
if (self.pre_exec) |f| f(self);
if (global_state.rlimits.nofile) |lim| {
internal_os.restoreMaxFiles(lim);
}
// Finally, replace our process.
_ = posix.execveZ(pathZ, argsZ, envp) catch null;