Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: setting resource limits



Oliver Kiddle wrote:
> Basically, the suggestion is that it should be possible to set resource
> limits numerically with e.g. `ulimit 4 1024'. I can see how this could
> be worth a lot to anyone implementing a new resource limit. Is that
> difficult to implement? Would it be vaguely portable?

It's easy if you impose limitations: e.g. `ulimit <number>' is treated
as setting RLIMIT_FSIZE, so you couldn't query limits like that (without an
extra option).  For example, the following (undocumented).

By the way, `ulimit -a' doesn't list the options applying to each limit
as it does in bash, so you're left guessing how to set the limit you
want.

Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.11
diff -u -r1.11 rlimits.c
--- Src/Builtins/rlimits.c	2 Jun 2004 22:14:47 -0000	1.11
+++ Src/Builtins/rlimits.c	14 Jun 2004 13:07:16 -0000
@@ -555,7 +555,9 @@
 		}
 	    }
 	}
-	if (!*argv || **argv == '-') {
+	if (res < 0 && *argv && idigit(**argv) && argv[1])
+	    res = (int)zstrtol(*argv++, NULL, 10);
+	else if (!*argv || **argv == '-') {
 	    if (res < 0) {
 		if (*argv || nres)
 		    continue;


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author