mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +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: https://github.com/LadybirdBrowser/ladybird/commit/0d6115e8ae3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/764
|
@ -1848,4 +1848,25 @@ ErrorOr<Bytes> allocate(size_t count, size_t size)
|
||||||
return Bytes { data, size * count };
|
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 <signal.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -289,4 +290,7 @@ ErrorOr<ByteString> current_executable_path();
|
||||||
|
|
||||||
ErrorOr<Bytes> allocate(size_t count, size_t size);
|
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