From 1c3c072a76d6a50987a9e00d088c4c8fa2562531 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 8 May 2021 05:04:56 +0200 Subject: [PATCH] LibC: Add stubs for getrlimit()/setrlimit() --- Userland/Libraries/LibC/sys/resource.h | 19 +++++++++++++++++++ Userland/Libraries/LibC/ulimit.cpp | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Userland/Libraries/LibC/sys/resource.h b/Userland/Libraries/LibC/sys/resource.h index 81dbb19be4a..0d1f2c9307b 100644 --- a/Userland/Libraries/LibC/sys/resource.h +++ b/Userland/Libraries/LibC/sys/resource.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -35,4 +36,22 @@ struct rusage { int getrusage(int who, struct rusage* usage); +#define RLIMIT_CORE 1 +#define RLIMIT_CPU 2 +#define RLIMIT_DATA 3 +#define RLIMIT_FSIZE 4 +#define RLIMIT_NOFILE 5 +#define RLIMIT_STACK 6 +#define RLIMIT_AS 7 + +#define RLIM_INFINITY SIZE_MAX + +struct rlimit { + size_t rlim_cur; + size_t rlim_max; +}; + +int getrlimit(int, struct rlimit*); +int setrlimit(int, struct rlimit const*); + __END_DECLS diff --git a/Userland/Libraries/LibC/ulimit.cpp b/Userland/Libraries/LibC/ulimit.cpp index af68309b934..4fa0e5fd370 100644 --- a/Userland/Libraries/LibC/ulimit.cpp +++ b/Userland/Libraries/LibC/ulimit.cpp @@ -23,4 +23,16 @@ int getrusage([[maybe_unused]] int who, [[maybe_unused]] struct rusage* usage) dbgln("FIXME: Implement getrusage()"); return -1; } + +int getrlimit([[maybe_unused]] int resource, rlimit* rl) +{ + rl->rlim_cur = RLIM_INFINITY; + rl->rlim_max = RLIM_INFINITY; + return 0; +} + +int setrlimit([[maybe_unused]] int resource, [[maybe_unused]] rlimit const* rl) +{ + return 0; +} }