diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-12-01 17:53:58 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-12-01 17:53:58 +0000 |
commit | 1c33c3a4447f90ef0c59ac839b48310efcbdca2e (patch) | |
tree | cc14ad186b13751315938537872336a4f44a6985 | |
parent | 2a9643f6aef1a52cdada648f72f1d0ec9c1b711d (diff) | |
download | s6-1c33c3a4447f90ef0c59ac839b48310efcbdca2e.tar.gz s6-1c33c3a4447f90ef0c59ac839b48310efcbdca2e.tar.xz s6-1c33c3a4447f90ef0c59ac839b48310efcbdca2e.zip |
s6-softlimit: don't use subgetopt_here
-rw-r--r-- | src/daemontools-extras/s6-softlimit.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c index 61e0e4d..6ddd779 100644 --- 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]) ; |