Raise RLIMIT_NPROC only if maxnprocs higher than current limits
All checks were successful
continuous-integration/drone/push Build is passing

Otherwise maxnprocs may actually lower the limit. Especially when using the
default limit of 512, this quickly causes quark's fork() to fail when started
with a non-exclusive user.

To mitigate this, we respect system defaults and only raise the limit if it is
an actual raise.
This commit is contained in:
Armin Friedl 2020-08-17 21:37:20 +02:00
parent 0144e4c783
commit d38603dc0e

7
main.c
View file

@ -285,7 +285,12 @@ main(int argc, char *argv[])
}
/* raise the process limit */
rlim.rlim_cur = rlim.rlim_max = maxnprocs;
if (getrlimit(RLIMIT_NPROC, &rlim) < 0) {
die("getrlimit RLIMIT_NPROC:");
}
rlim.rlim_cur = MAX(rlim.rlim_cur, maxnprocs);
rlim.rlim_max = MAX(rlim.rlim_max, maxnprocs);
if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
die("setrlimit RLIMIT_NPROC:");
}