LibCore: Respect system hard limit in set_resource_limits

This avoids an "Invalid argument (errno=22)" error
on systems with lower hard limits.

(cherry picked from commit c97af00355159b0dac9019b885af7c6016e75dc7)
This commit is contained in:
Jonne Ransijn 2024-10-27 20:04:20 +01:00 committed by Nico Weber
parent de1ecc17ce
commit 095c076941

View file

@ -1907,7 +1907,7 @@ ErrorOr<rlimit> get_resource_limits(int resource)
ErrorOr<void> set_resource_limits(int resource, rlim_t limit)
{
auto limits = TRY(get_resource_limits(resource));
limits.rlim_cur = limit;
limits.rlim_cur = min(limit, limits.rlim_max);
if (::setrlimit(resource, &limits) != 0)
return Error::from_syscall("setrlimit"sv, -errno);