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 <kikuchi@centurysys.co.jp>
This commit is contained in:
Takeyoshi Kikuchi
2023-02-17 13:42:31 +09:00
committed by Xiang Xiao
parent fff0e58860
commit 2e5a20612c
+14
View File
@@ -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;
}