mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 01:32:14 -05: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: https://github.com/LadybirdBrowser/ladybird/commit/0d6115e8ae3 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 {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <signal.h>
|
||||
#include <spawn.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -289,4 +290,7 @@ ErrorOr<ByteString> current_executable_path();
|
|||
|
||||
ErrorOr<Bytes> allocate(size_t count, size_t size);
|
||||
|
||||
ErrorOr<rlimit> get_resource_limits(int resource);
|
||||
ErrorOr<void> set_resource_limits(int resource, rlim_t limit);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue