From 2e5a20612c75c24dee764f0599afa47404d4a19c Mon Sep 17 00:00:00 2001 From: Takeyoshi Kikuchi Date: Fri, 17 Feb 2023 13:42:31 +0900 Subject: [PATCH] libc: unistd: lib_getrlimit: return a value for RLIMIT_NOFILE request. In the Nim language "selectors"(I/O multiplexing) module, the maximum number of file descriptors is obtained with getrlimit() as follows. var fdLim: RLimit var res = int(getrlimit(RLIMIT_NOFILE, fdLim)) if res >= 0: res = int(fdLim.rlim_cur) - 1 To be able to use the same implementation as other POSIX-based OS, getrlimit() should return a value. (For now, let it return 128.) Signed-off-by: Takeyoshi Kikuchi --- libs/libc/unistd/lib_getrlimit.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/libc/unistd/lib_getrlimit.c b/libs/libc/unistd/lib_getrlimit.c index efcd1fcdd20..7c4815f6154 100644 --- a/libs/libc/unistd/lib_getrlimit.c +++ b/libs/libc/unistd/lib_getrlimit.c @@ -55,5 +55,19 @@ int getrlimit(int resource, FAR struct rlimit *rlp) /* This is a dummy realization to make the compiler happy */ memset(rlp, 0, sizeof(*rlp)); + + switch (resource) + { + case RLIMIT_NOFILE: + { + rlp->rlim_cur = 128; + rlp->rlim_max = 1024 * 1024; /* dummy */ + } + break; + + default: + break; + } + return OK; }