Raise RLIMIT_NPROC only if maxnprocs higher than current limits
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
0144e4c783
commit
d38603dc0e
1 changed files with 14 additions and 9 deletions
7
main.c
7
main.c
|
@ -285,7 +285,12 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* raise the process limit */
|
/* 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) {
|
if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
|
||||||
die("setrlimit RLIMIT_NPROC:");
|
die("setrlimit RLIMIT_NPROC:");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue