* [PATCH 15/15] prlimit: fix displaying of modified limits
@ 2011-11-14 1:48 Bernhard Voelker
2011-11-16 13:08 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Voelker @ 2011-11-14 1:48 UTC (permalink / raw)
To: util-linux
[PATCH 15/15] prlimit: fix displaying of modified limits
When a limit is to be modified and shown, e.g. in
$ prlimit -p$$ -n1000 -n
then the prlimit syscall has overwritten lims[i].rlim with the old value.
For such cases, copy the new values afterwards again.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
sys-utils/prlimit.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 69440a5..bfe8005 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -333,6 +333,7 @@ static void do_prlimit(struct prlimit lims[], int
tt_flags)
for (i = 0; i < MAX_RESOURCES; i++) {
struct rlimit *new = NULL;
+ struct rlimit new_rlim;
if (lims[i].modify) {
if (!pid)
@@ -348,7 +349,9 @@ static void do_prlimit(struct prlimit lims[], int
tt_flags)
lims[i].rlim.rlim_max != RLIM_INFINITY))
errx(EXIT_FAILURE, _("the soft limit cannot exceed the ceiling
value"));
- new = &lims[i].rlim;
+ new_rlim.rlim_cur = lims[i].rlim.rlim_cur;
+ new_rlim.rlim_max = lims[i].rlim.rlim_max;
+ new = &new_rlim;
} else if (!(lims[i].show)) {
continue;
}
@@ -383,6 +386,15 @@ static void do_prlimit(struct prlimit lims[], int
tt_flags)
lims[i].desc->name);
}
}
+ if (lims[i].modify && new) {
+ /*
+ * prlimit has overwritten lims[i].rlim with the old value.
+ * In the case we have to display the new value, we have to
+ * copy it from new_rlim again.
+ */
+ lims[i].rlim.rlim_cur = new_rlim.rlim_cur;
+ lims[i].rlim.rlim_max = new_rlim.rlim_max;
+ }
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 15/15] prlimit: fix displaying of modified limits
2011-11-14 1:48 [PATCH 15/15] prlimit: fix displaying of modified limits Bernhard Voelker
@ 2011-11-16 13:08 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2011-11-16 13:08 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux
On Mon, Nov 14, 2011 at 02:48:56AM +0100, Bernhard Voelker wrote:
> [PATCH 15/15] prlimit: fix displaying of modified limits
>
> When a limit is to be modified and shown, e.g. in
> $ prlimit -p$$ -n1000 -n
> then the prlimit syscall has overwritten lims[i].rlim with the old value.
> For such cases, copy the new values afterwards again.
This is also unnecessary now, but I have a little improved this
thing, so the syscall is not called with the same pointer for new and
old argument now.
Thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-16 13:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 1:48 [PATCH 15/15] prlimit: fix displaying of modified limits Bernhard Voelker
2011-11-16 13:08 ` Karel Zak
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).