* [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits
@ 2011-11-14 1:48 Bernhard Voelker
2011-11-16 12:45 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Bernhard Voelker @ 2011-11-14 1:48 UTC (permalink / raw)
To: util-linux
[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.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
sys-utils/prlimit.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 6943d11..9a52b81 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -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);
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits
2011-11-14 1:48 [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits Bernhard Voelker
@ 2011-11-16 12:45 ` Karel Zak
2011-11-16 15:05 ` Bernhard Voelker
2011-11-16 15:05 ` Bernhard Voelker
0 siblings, 2 replies; 5+ messages in thread
From: Karel Zak @ 2011-11-16 12:45 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux
On Mon, Nov 14, 2011 at 02:48:11AM +0100, Bernhard Voelker wrote:
> + 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
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits
2011-11-16 12:45 ` Karel Zak
@ 2011-11-16 15:05 ` Bernhard Voelker
2011-11-16 15:55 ` Karel Zak
2011-11-16 15:05 ` Bernhard Voelker
1 sibling, 1 reply; 5+ messages in thread
From: Bernhard Voelker @ 2011-11-16 15:05 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On 11/16/2011 01:45 PM, Karel Zak wrote:
> Anyway, it would be nice to have something like:
>
> prlimit --nofile=1000 /bin/program
>
> so somewhere after show_limits() should be exec().
Great idea. ;-)
Would you like me to give it a try?
Have a nice day,
Berny
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits
2011-11-16 12:45 ` Karel Zak
2011-11-16 15:05 ` Bernhard Voelker
@ 2011-11-16 15:05 ` Bernhard Voelker
1 sibling, 0 replies; 5+ messages in thread
From: Bernhard Voelker @ 2011-11-16 15:05 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On 11/16/2011 01:45 PM, Karel Zak wrote:
> On Mon, Nov 14, 2011 at 02:48:11AM +0100, Bernhard Voelker wrote:
>> > + 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-16 15:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 1:48 [PATCH 04/15] prlimit: add warning diagnostic when attempting to change prlimit's limits Bernhard Voelker
2011-11-16 12:45 ` Karel Zak
2011-11-16 15:05 ` Bernhard Voelker
2011-11-16 15:55 ` Karel Zak
2011-11-16 15:05 ` Bernhard Voelker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).