prlimit: give better diagnostic for illegal hard limit case
PATCH 8/15 prlimit: give better diagnostic for illegal hard limit case
[PATCH 08/15] prlimit: give better diagnostic for illegal hard limit case
Give better diagnostic in cases where the user only specifies a new hard limit, but when that is lower than the current hard limit.
Example:
$ prlimit -n -p7852 --noheadings NOFILE max amount of open files 1024 8192
Previous message:
$ prlimit -n:1000 -p7852 prlimit: the soft limit cannot exceed the ceiling value
New message:
$ prlimit -n:1000 -p7852 prlimit: current soft limit NOFILE is greater than new hard limit
Signed-off-by Bernhard Voelker <[email protected]>
--- sys-utils/prlimit.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
sys-utils/prlimit.c +11 -0
@@ -313,6 +313,17 @@ static void get_unknown_hardsoft(struct prlimit *lim) lim->rlim.rlim_cur = old.rlim_cur; else if (!(lim->found & PRLIMIT_HARD)) lim->rlim.rlim_max = old.rlim_max; + +/* give better diagnostic in cases where the new hard limit +* would be lower than the current soft limit, and the user +* did not give a new soft limit. +*/ +if (!(lim->found &PRLIMIT_SOFT ) && + (lim->rlim.rlim_cur > lim->rlim.rlim_max)) { +errx (EXIT_FAILURE , +_ ("current soft limit %s is greater than new hard limit" ), + lim->desc->name); + } } }