* [PATCH 03/15] prlimit: fix diagnostic when setting current PIDs resources fails
@ 2011-11-14 1:48 Bernhard Voelker
2011-11-16 12:41 ` 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 03/15] prlimit: fix diagnostic when setting current PIDs
resources fails
Avoids wrong message:
$ prlimit --nofile=16000
prlimit: failed to get resource limits for PID 0: Operation not permitted
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
---
sys-utils/prlimit.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 525351a..6943d11 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -320,8 +320,12 @@ static void do_prlimit(struct prlimit lims[],
size_t n, int tt_flags)
printf(":%ju>\n", new->rlim_max);
}
- if (prlimit(pid, lims[i].desc->resource, new, &lims[i].rlim) == -1)
- err(EXIT_FAILURE, _("failed to get resource limits for PID %d"), pid);
+ if (prlimit(pid, lims[i].desc->resource, new, &lims[i].rlim) == -1) {
+ if (pid)
+ err(EXIT_FAILURE, _("failed to get resource limits for PID %d"), pid);
+ else
+ err(EXIT_FAILURE, _("failed to get resource limits of the current
process"));
+ }
}
if (nshows)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 03/15] prlimit: fix diagnostic when setting current PIDs resources fails
2011-11-14 1:48 [PATCH 03/15] prlimit: fix diagnostic when setting current PIDs resources fails Bernhard Voelker
@ 2011-11-16 12:41 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2011-11-16 12:41 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux
On Mon, Nov 14, 2011 at 02:48:07AM +0100, Bernhard Voelker wrote:
> [PATCH 03/15] prlimit: fix diagnostic when setting current PIDs
> resources fails
Not applied, but I have improved the error messages according to your
5-8 patches.
> - err(EXIT_FAILURE, _("failed to get resource limits for PID %d"), pid);
> + if (prlimit(pid, lims[i].desc->resource, new, &lims[i].rlim) == -1) {
> + if (pid)
> + err(EXIT_FAILURE, _("failed to get resource limits for PID %d"), pid);
> + else
> + err(EXIT_FAILURE, _("failed to get resource limits of the current
> process"));
I think we don't have to care about the PID in the error message at
all. The util works always with one PID only.
"failed to set the %s resource limit"
or
"failed to get the %s resource limit"
seems enough :-)
Karel
--
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 12:41 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 03/15] prlimit: fix diagnostic when setting current PIDs resources fails Bernhard Voelker
2011-11-16 12:41 ` 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).