~kaction/runit

38c2215782ecff692b5e05706bd1932206003d33 — Dmitry Bogatov 8 months ago 1fea9d4 master
chpst: allow specifying "infinity" values for limits

Previously, compatibility modes of chpst(1) (softlimit, pgrphack and rest)
recognized "=" argument as infinity value, but native chpst mode did not. Now
in all scenarios chpst(1) behaves consistently and recognizes "=" argument.

Signed-off-by: Dmitry Bogatov <git#v1@kaction.cc>
1 files changed, 8 insertions(+), 7 deletions(-)

M src/chpst.c
M src/chpst.c => src/chpst.c +8 -7
@@ 27,6 27,7 @@
const char *progname;
static stralloc sa;

extern void getlarg(long *);
void fatal(const char *m) { strerr_die3sys(111, FATAL, m, ": "); }
void fatal2(const char *m0, const char *m1) {
  strerr_die5sys(111, FATAL, m0, ": ", m1, ": ");


@@ 297,13 298,13 @@ int main(int argc, const char **argv) {
      if (optarg[scan_ulong(optarg, &ul)]) usage();
      limits =limitl =limita =limitd =ul;
      break;
    case 'd': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitd =ul; break;
    case 'o': if (optarg[scan_ulong(optarg, &ul)]) usage(); limito =ul; break;
    case 'p': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitp =ul; break;
    case 'f': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitf =ul; break;
    case 'c': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitc =ul; break;
    case 'r': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitr =ul; break;
    case 't': if (optarg[scan_ulong(optarg, &ul)]) usage(); limitt =ul; break;
    case 'd': getlarg(&limitd); break;
    case 'o': getlarg(&limito); break;
    case 'p': getlarg(&limitp); break;
    case 'f': getlarg(&limitf); break;
    case 'c': getlarg(&limitc); break;
    case 'r': getlarg(&limitr); break;
    case 't': getlarg(&limitt); break;
    case '/': root =optarg; break;
    case 'n':
      switch (*optarg) {