Move resource limits to a dedicated struct, restore before preexec

This commit is contained in:
Mitchell Hashimoto
2025-01-02 15:04:49 -08:00
parent 9ea0aa4934
commit 8e47d0267b
3 changed files with 26 additions and 14 deletions

View File

@@ -176,13 +176,13 @@ fn startPosix(self: *Command, arena: Allocator) !void {
// We don't log because that'll show up in the output.
};
// Restore any rlimits that were set by Ghostty. This might fail but
// any failures are ignored (its best effort).
global_state.rlimits.restore();
// 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;