s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 1c33c3a4447f90ef0c59ac839b48310efcbdca2e
parent 2a9643f6aef1a52cdada648f72f1d0ec9c1b711d
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Thu,  1 Dec 2016 17:53:58 +0000

 s6-softlimit: don't use subgetopt_here

Diffstat:
Msrc/daemontools-extras/s6-softlimit.c | 43+++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c @@ -1,8 +1,6 @@ /* ISC license. */ #include <sys/types.h> -#include <time.h> -#include <sys/time.h> #include <sys/resource.h> #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> @@ -23,94 +21,95 @@ static void doit (int res, char const *arg) if (n > (uint64)r.rlim_max) n = (uint64)r.rlim_max ; r.rlim_cur = (rlim_t)n ; } - if (setrlimit(res, &r) == -1) strerr_diefu1sys(111, "setrlimit") ; + if (setrlimit(res, &r) < 0) strerr_diefu1sys(111, "setrlimit") ; } int main (int argc, char const *const *argv, char const *const *envp) { + subgetopt_t l = SUBGETOPT_ZERO ; PROG = "s6-softlimit" ; for (;;) { - register int opt = sgetopt(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:") ; + register int opt = subgetopt_r(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", &l) ; if (opt == -1) break ; switch (opt) { case 'a' : #ifdef RLIMIT_AS - doit(RLIMIT_AS, subgetopt_here.arg) ; + doit(RLIMIT_AS, l.arg) ; #endif #ifdef RLIMIT_VMEM - doit(RLIMIT_VMEM, subgetopt_here.arg) ; + doit(RLIMIT_VMEM, l.arg) ; #endif break ; case 'c' : #ifdef RLIMIT_CORE - doit(RLIMIT_CORE, subgetopt_here.arg) ; + doit(RLIMIT_CORE, l.arg) ; #endif break ; case 'd' : #ifdef RLIMIT_DATA - doit(RLIMIT_DATA, subgetopt_here.arg) ; + doit(RLIMIT_DATA, l.arg) ; #endif break ; case 'f' : #ifdef RLIMIT_FSIZE - doit(RLIMIT_FSIZE, subgetopt_here.arg) ; + doit(RLIMIT_FSIZE, l.arg) ; #endif break ; case 'l' : #ifdef RLIMIT_MEMLOCK - doit(RLIMIT_MEMLOCK, subgetopt_here.arg) ; + doit(RLIMIT_MEMLOCK, l.arg) ; #endif break ; case 'm' : #ifdef RLIMIT_DATA - doit(RLIMIT_DATA, subgetopt_here.arg) ; + doit(RLIMIT_DATA, l.arg) ; #endif #ifdef RLIMIT_STACK - doit(RLIMIT_STACK, subgetopt_here.arg) ; + doit(RLIMIT_STACK, l.arg) ; #endif #ifdef RLIMIT_MEMLOCK - doit(RLIMIT_MEMLOCK, subgetopt_here.arg) ; + doit(RLIMIT_MEMLOCK, l.arg) ; #endif #ifdef RLIMIT_VMEM - doit(RLIMIT_VMEM, subgetopt_here.arg) ; + doit(RLIMIT_VMEM, l.arg) ; #endif #ifdef RLIMIT_AS - doit(RLIMIT_AS, subgetopt_here.arg) ; + doit(RLIMIT_AS, l.arg) ; #endif break ; case 'o' : #ifdef RLIMIT_NOFILE - doit(RLIMIT_NOFILE, subgetopt_here.arg) ; + doit(RLIMIT_NOFILE, l.arg) ; #endif #ifdef RLIMIT_OFILE - doit(RLIMIT_OFILE, subgetopt_here.arg) ; + doit(RLIMIT_OFILE, l.arg) ; #endif break ; case 'p' : #ifdef RLIMIT_NPROC - doit(RLIMIT_NPROC, subgetopt_here.arg) ; + doit(RLIMIT_NPROC, l.arg) ; #endif break ; case 'r' : #ifdef RLIMIT_RSS - doit(RLIMIT_RSS, subgetopt_here.arg) ; + doit(RLIMIT_RSS, l.arg) ; #endif break ; case 's' : #ifdef RLIMIT_STACK - doit(RLIMIT_STACK, subgetopt_here.arg) ; + doit(RLIMIT_STACK, l.arg) ; #endif break ; case 't' : #ifdef RLIMIT_CPU - doit(RLIMIT_CPU, subgetopt_here.arg) ; + doit(RLIMIT_CPU, l.arg) ; #endif break ; } } - argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; + argc -= l.ind ; argv += l.ind ; if (!argc) strerr_dieusage(100, USAGE) ; pathexec_run(argv[0], argv, envp) ; strerr_dieexec(111, argv[0]) ;