[PATCH s6] s6-softlimit: add -P option for RLIMIT_RTPRIO

From: Alyssa Ross <hi_at_alyssa.is>
Date: Sun, 9 Nov 2025 18:32:14 +0100

Bash ulimit uses -r for this, but in s6-softlimit that was already
taken. I could have used -R, but Bash uses that for RLIMIT_RTTIME, so
I didn't want to claim that one and create a similarly difficult
decision for somebody adding that in future. I decided to use -P (for
"priority") as the least bad still-available option.
---
 doc/s6-softlimit.html                 | 3 ++-
 src/daemontools-extras/s6-softlimit.c | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/s6-softlimit.html b/doc/s6-softlimit.html
index 05701ce..49a5b40 100644
--- a/doc/s6-softlimit.html
+++ b/doc/s6-softlimit.html
_at__at_ -25,7 +25,7 _at__at_ s6-softlimit changes its process limits, then executes into another program.
 <h2> Interface </h2>
 
 <pre>
-     s6-softlimit [ -H | -h ] [ -a <em>allmem</em> ] [ -c <em>core</em> ] [ -d <em>data</em> ] [ -f <em>fsize</em> ] [ -l <em>lock</em> ] [ -m <em>mem</em> ] [ -o <em>ofiles</em> ] [ -p <em>proc</em> ] [ -r <em>res</em> ] [ -s <em>stack</em> ] [ -t <em>cpusecs</em> ] <em>prog...</em>
+     s6-softlimit [ -H | -h ] [ -a <em>allmem</em> ] [ -c <em>core</em> ] [ -d <em>data</em> ] [ -f <em>fsize</em> ] [ -l <em>lock</em> ] [ -m <em>mem</em> ] [ -o <em>ofiles</em> ] [ -P <em>prio</em> ] [ -p <em>proc</em> ] [ -r <em>res</em> ] [ -s <em>stack</em> ] [ -t <em>cpusecs</em> ] <em>prog...</em>
 </pre>
 
 <ul>
_at__at_ -58,6 +58,7 _at__at_ and s6-softlimit will die. There is virtually no reason to ever use this. </li>
  <li> <tt>-l&nbsp;<em>lock</em></tt>&nbsp;: limit the available locked memory to <em>lock</em> bytes. </li>
  <li> <tt>-m&nbsp;<em>mem</em></tt>&nbsp;: limit all types of memory to <em>mem</em> bytes. </li>
  <li> <tt>-o&nbsp;<em>ofiles</em></tt>&nbsp;: limit the number of open fds to <em>ofiles</em>. </li>
+ <li> <tt>-P&nbsp;<em>prio</em></tt>&nbsp;: limit the real-time priority to <em>prio</em>. </li>
  <li> <tt>-p&nbsp;<em>proc</em></tt>&nbsp;: limit the number of processes to <em>proc</em> (per user). </li>
  <li> <tt>-r&nbsp;<em>res</em></tt>&nbsp;: limit the available physical memory to <em>res</em> bytes. </li>
  <li> <tt>-s&nbsp;<em>stack</em></tt>&nbsp;: limit the available stack memory to <em>stack</em> bytes. </li>
diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c
index d6112b2..beb7325 100644
--- a/src/daemontools-extras/s6-softlimit.c
+++ b/src/daemontools-extras/s6-softlimit.c
_at__at_ -41,7 +41,7 _at__at_ int main (int argc, char const *const *argv)
   PROG = "s6-softlimit" ;
   for (;;)
   {
-    int opt = subgetopt_r(argc, argv, "hHa:c:d:f:l:m:o:p:r:s:t:", &l) ;
+    int opt = subgetopt_r(argc, argv, "hHa:c:d:f:l:m:o:P:p:r:s:t:", &l) ;
     if (opt == -1) break ;
     switch (opt)
     {
_at__at_ -103,6 +103,11 _at__at_ int main (int argc, char const *const *argv)
       case 'p' :
 #ifdef RLIMIT_NPROC
         doit(RLIMIT_NPROC, l.arg) ;
+#endif
+        break ;
+      case 'P' :
+#ifdef RLIMIT_RTPRIO
+        doit(RLIMIT_RTPRIO, l.arg) ;
 #endif
         break ;
       case 'r' :
base-commit: a456cc8c4123e05f8d6c3620979961add7f0ed4e
-- 
2.51.0
Received on Sun Nov 09 2025 - 18:32:14 CET

This archive was generated by hypermail 2.4.0 : Sun Nov 09 2025 - 18:32:58 CET