Skip to content

Commit

Permalink
LibCore: Respect system hard limit in set_resource_limits
Browse files Browse the repository at this point in the history
This avoids an "Invalid argument (errno=22)" error
on systems with lower hard limits.
  • Loading branch information
yyny authored and trflynn89 committed Oct 27, 2024
1 parent c5a54f1 commit c97af00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibCore/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,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);
Expand Down

0 comments on commit c97af00

Please sign in to comment.