mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
LibCore: Add system call wrappers around getrlimit and setrlimit
This commit is contained in:
parent
7b10eb7225
commit
0d6115e8ae
Notes:
github-actions[bot]
2024-07-23 07:40:42 +00:00
Author: https://github.com/trflynn89
Commit: 0d6115e8ae
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/764
2 changed files with 25 additions and 0 deletions
|
@ -1848,4 +1848,25 @@ ErrorOr<Bytes> allocate(size_t count, size_t size)
|
|||
return Bytes { data, size * count };
|
||||
}
|
||||
|
||||
ErrorOr<rlimit> get_resource_limits(int resource)
|
||||
{
|
||||
rlimit limits;
|
||||
|
||||
if (::getrlimit(resource, &limits) != 0)
|
||||
return Error::from_errno(errno);
|
||||
|
||||
return limits;
|
||||
}
|
||||
|
||||
ErrorOr<void> set_resource_limits(int resource, rlim_t limit)
|
||||
{
|
||||
auto limits = TRY(get_resource_limits(resource));
|
||||
limits.rlim_cur = limit;
|
||||
|
||||
if (::setrlimit(resource, &limits) != 0)
|
||||
return Error::from_errno(errno);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue