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

Re: setting resource limits



A much nicer way of doing it is with an explicit option to give the
number of the limit.  This is more consistent with normal ulimit
behaviour.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.68
diff -u -r1.68 builtins.yo
--- Doc/Zsh/builtins.yo	21 May 2004 20:04:59 -0000	1.68
+++ Doc/Zsh/builtins.yo	14 Jun 2004 15:19:24 -0000
@@ -1406,7 +1406,7 @@
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ tt(-SHacdflmnpstv) [ var(limit) ] ... ])(
+item(tt(ulimit) [ tt(-SHacdflmnpstv) [ tt(-N) var(type) ] [ var(limit) ] ... ])(
 Set or display resource limits of the shell and the processes started by
 the shell.  The value of var(limit) can be a number in the unit specified
 below or the value `tt(unlimited)'.  By default, only soft limits are
@@ -1432,6 +1432,11 @@
 sitem(tt(-v))(K-bytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
 endsitem()
+
+Alternatively, the limit can be given by number using tt(-N) var(limit).
+This can be used to set a limit known to the operating system, but
+not to the shell.  Limits are typically given in the file
+tt(/usr/include/sys/resource.h), or a file included from there.
 )
 findex(umask)
 cindex(umask)
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 15:19:24 -0000
@@ -485,6 +485,23 @@
 		case 'S':
 		    soft = 1;
 		    continue;
+		case 'N':
+		    if (options[1]) {
+			res = (int)zstrtol(options+1, NULL, 10);
+			argv++;
+		    } else if (*argv) {
+			res = (int)zstrtol(*argv++, NULL, 10);
+		    } else {
+			zwarnnam(name, "number required after -N",
+				 NULL, 0);
+			return 1;
+		    }
+		    /*
+		     * fake it so it looks like we just finished an option...
+		     */
+		    while (options[1])
+			options++;
+		    break;
 		case 'a':
 		    if (resmask) {
 			zwarnnam(name, "no limits allowed with -a",


-- 
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