prlimit: add warning diagnostic when attempting to change prlimit's limits
PATCH 4/15 prlimit: add warning diagnostic when attempting to change prlimit's limits
[PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits
Setting the limits of the prlimit process is useless because it will exit shortly anyway. To help the user not to fall into this trap, prlimit now displays a warning.
--- sys-utils/prlimit.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
sys-utils/prlimit.c +5 -2
@@ -302,10 +302,13 @@ static void do_prlimit(struct prlimit lims[], size_t n, int tt_flags)for (i =0 ; i < n; i++) {struct rlimit *new =NULL ; -if (lims[i].modify) +if (lims[i].modify) { +if (!pid) +warnx (_ ("setting limits of the prlimit process is pointless" )); new = &lims[i].rlim; -else + }else { nshows++; + }if (verbose && new) {printf (_ ("New %s limit: " ), lims[i].desc->name);
Karel Zak
maintainersys-utils/prlimit.c static void do_prlimit(struct prlimit lims[], size_t n, int tt_flags) · line 307
Quoted 3 lines · Bernhard Voelker
sys-utils/prlimit.c +3
-0+if (lims[i].modify) { +if (!pid) +warnx (_ ("setting limits of the prlimit process is pointless" ));
Well, I don't think that we want such warnings in our utils :-) Let's inform users about errors, the rest should be described in man pages.
Anyway, it would be nice to have something like:
prlimit --nofile=1000 /bin/program
so somewhere after show_limits() should be exec().
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 5 lines · Karel Zak
Anyway, it would be nice to have something like:
prlimit --nofile=1000 /bin/programso somewhere after
show_limits()should beexec().
Great idea. ;-)
Would you like me to give it a try?
Have a nice day,
Berny
Karel Zak
maintainerQuoted 10 lines · Bernhard Voelker
Quoted 5 lines · Karel Zak
Anyway, it would be nice to have something like:
prlimit --nofile=1000 /bin/programso somewhere after
show_limits()should beexec().Great idea. ;-)
Would you like me to give it a try?
Sure, go ahead!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 7 lines · Karel Zak
Quoted 3 lines · Bernhard Voelker
Quoted 3 lines
+ if (lims[i].modify) {
+ if (!pid)
+warnx(_("setting limits of the prlimit process is pointless"));Well, I don't think that we want such warnings in our utils:-) Let's inform users about errors, the rest should be described in man pages.
hmm, then I tend to make it an error: prlimit acts too similar to ulimit, but the *big* difference - and therefore the *big* trap for the user - is that ulimit is a shell builtin which affects the current shell process whereas prlimit runs in it's own process and, as a result, will just do not have an effect without a PID.
Have a nice day,
Berny