On 2013-05-23 09:14, Denys Vlasenko wrote:
On Thu, May 23, 2013 at 4:53 AM, Joshua Judson Rosen
<[email protected]> wrote:
The attached patch adds a new shell builtin, "prlimit", which is similar
to ulimit but can operate on any process (not just the current process),
by using Linux's prlimit() function.
prlimit takes a PID as a first argument, and then processes the rest of
its arguments identically to ulimit, e.g.:
prlimit 3431 -c unlimited
Maybe this is of general interest?
On, for example, Fedora, prlimit is an executable
(as opposed to shell built-in).
Therefore, it better be an applet in busybox, not built-in.
Oh, OK. I missed the fact that prlimit already existed as a command somewhere--
it looks like that was new in util-linux 2.21 (last year; and Debian and Ubuntu
are still on util-linux 2.20).
util-linux's prlimit also appears to have a completely different argument-syntax
than ulimit; I should re-write my applet to match that syntax.
Another note:
+#if ENABLE_FEATURE_PRLIMIT
+ prlimit(pid, l->cmd, NULL,&limit);
+#else
getrlimit(l->cmd,&limit);
+#endif
What's the rationale behind this change?
Just simplicity--since the getrlimit() call is equivalent to the prlimit() call
with pid=0, just always using prlimit meant that I only had to check once
whether the command being executed was "ulimit" or "prlimit" (so, in the shell,
"ulimit ..." effectively became equivalent to "prlimit 0 ..."). I had figured
the prlimit shell command should be able to read the limits of other processes
as well as set them (e.g.: "prlimit 1 -a" to show the the limits in effect
for the init process).
--
"Don't be afraid to ask (λf.((λx.xx) (λr.f(rr))))."
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox