This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b3ccc007911 include/sys/resource.h: Add four resource limits of Linux
and BSD.
b3ccc007911 is described below
commit b3ccc007911fa25e6bc40856c053eb27450b8d14
Author: Marco Casaroli <[email protected]>
AuthorDate: Mon Oct 26 01:03:23 2026 +0100
include/sys/resource.h: Add four resource limits of Linux and BSD.
RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_LOCKS and RLIMIT_SIGPENDING were
missing. Linux and the BSDs have them, and programs use them without a
check (the ulimit command of shells, for example). Such programs did not
compile.
Add them at the free values 9, 11, 12 and 13. NuttX does not enforce
them: getrlimit() reports RLIM_INFINITY, as for the other limits that
NuttX does not enforce, and setrlimit() fails with EINVAL, as for those.
RLIM_NLIMITS does not change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
include/sys/resource.h | 4 ++++
sched/group/group_rlimit.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 56bd4e14f5c..093455a04ae 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -60,10 +60,14 @@
#define RLIMIT_STACK 6 /* Limit on stack size */
#define RLIMIT_AS 7 /* Limit on address space size */
#define RLIMIT_MEMLOCK 8 /* Limit on memory use */
+#define RLIMIT_RSS 9 /* Limit on resident set size */
#define RLIMIT_NICE 10 /* Limit on nice level */
/* Below are not implemented yet: */
+#define RLIMIT_NPROC 11 /* Limit on processes of the user */
+#define RLIMIT_LOCKS 12 /* Limit on file locks */
+#define RLIMIT_SIGPENDING 13 /* Limit on queued signals */
#define RLIMIT_RTPRIO 14 /* Limit on RT tasks priority */
#define RLIMIT_RTTIME 15 /* Limit on timeout for RT tasks (us) */
diff --git a/sched/group/group_rlimit.c b/sched/group/group_rlimit.c
index 730c8def329..03bfbd2375a 100644
--- a/sched/group/group_rlimit.c
+++ b/sched/group/group_rlimit.c
@@ -139,6 +139,10 @@ int getrlimit(int resource, FAR struct rlimit *rlp)
case RLIMIT_FSIZE:
case RLIMIT_AS:
case RLIMIT_MEMLOCK:
+ case RLIMIT_RSS:
+ case RLIMIT_NPROC:
+ case RLIMIT_LOCKS:
+ case RLIMIT_SIGPENDING:
rlp->rlim_cur = RLIM_INFINITY;
rlp->rlim_max = RLIM_INFINITY;
break;