[PATCH 03/15] prlimit: fix diagnostic when setting current PIDs resources fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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@xxxxxxxxxxxxxxxxxxx>
---
 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)
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux