diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-02-26 03:52:56 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-02-26 03:52:56 +0000 |
commit | 5ec0b70b9b0cc387287a1eb3e7aef06a42706eae (patch) | |
tree | daf03da8477c8293cf0772667070e813962e8c04 /src | |
parent | fd69f337d8bf6ba3aa1c8418edc07ee899f84eb2 (diff) | |
download | s6-5ec0b70b9b0cc387287a1eb3e7aef06a42706eae.tar.xz |
Prepare for 2.11.3.1, rlimit shenanigans
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/daemontools-extras/s6-softlimit.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c index f9db3a6..b1bf615 100644 --- a/src/daemontools-extras/s6-softlimit.c +++ b/src/daemontools-extras/s6-softlimit.c @@ -10,17 +10,27 @@ #define USAGE "s6-softlimit [ -a allbytes ] [ -c corebytes ] [ -d databytes ] [ -f filebytes ] [ -l lockbytes ] [ -m membytes ] [ -o openfiles ] [ -p processes ] [ -r residentbytes ] [ -s stackbytes ] [ -t cpusecs ] prog..." +static int what = 1 ; + static void doit (int res, char const *arg) { struct rlimit r ; if (getrlimit(res, &r) < 0) strerr_diefu1sys(111, "getrlimit") ; - if ((arg[0] == '=') && !arg[1]) r.rlim_cur = r.rlim_max ; + if ((arg[0] == '=') && !arg[1]) + { + if (what & 2) r.rlim_max = RLIM_INFINITY ; + if (what & 1) r.rlim_cur = r.rlim_max ; + } else { uint64_t n ; if (!uint640_scan(arg, &n)) strerr_dieusage(100, USAGE) ; - if (n > (uint64_t)r.rlim_max) n = (uint64_t)r.rlim_max ; - r.rlim_cur = (rlim_t)n ; + if (what & 2) r.rlim_max = n ; + if (what & 1) + { + if (n > r.rlim_max) n = r.rlim_max ; + r.rlim_cur = n ; + } } if (setrlimit(res, &r) < 0) strerr_diefu1sys(111, "setrlimit") ; } @@ -31,10 +41,12 @@ int main (int argc, char const *const *argv) PROG = "s6-softlimit" ; for (;;) { - int opt = subgetopt_r(argc, argv, "a: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:r:s:t:", &l) ; if (opt == -1) break ; switch (opt) { + case 'h' : what = 2 ; break ; + case 'H' : what = 3 ; break ; case 'a' : #ifdef RLIMIT_AS doit(RLIMIT_AS, l.arg) ; |