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

PATCH: Re: add more ulimit extensions from BSDs



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:

> On Oct 30, 10:59am, Peter Stephenson wrote:
> } Subject: Re: PATCH: add more ulimit extensions from BSDs
> }
> } > while sh's ulimit -a describes them as
> } > 
> } >   kqueues                         (-k)  unlimited
> } > 
> } > and DragonFly only has
> } > 
> } >   posixlocks                      (-k)  unlimited
> } 
> } Thanks for the changes... are we sure that posixlocks and kqueues are
> } mutually incompatible, or should we move one to -K via #define's if both
> } exist?
>
> It makes me nervous to have two limits on the same option letter even if
> they are not mutually incompatible.  Lots of people (including me) have
> "portable" RC files.

Here's incomplete list of quirks:

  ulimit:
   -T maxpthreads (bash) vs. -N X maxpthreads (zsh)[*]
   -p pipesize (any bash) vs. -p pseudoterminals (freebsd sh)
   -r threads (netbsd sh) vs. -r rt_priority (linux bash, zsh)[*]
   -k posixlocks (dragonfly sh) vs. -k kqueues (freebsd sh)
  limit:
   maxthread (login.conf) vs. threads (tcsh) vs. maxthr (zsh)
   sbsize (login.conf, tcsh) vs. sockbufsize (zsh)
   swapuse (login.conf) vs. swapsize (tcsh)
   vmemoryuse (tcsh, login.conf) vs. vmemorysize (zsh)

After discussing a bit on FreeBSD side and looking at a patch for bash
I'd go with re-using an existing -x option letter and fix [*] as well.

http://lists.freebsd.org/pipermail/svn-src-head/2013-October/052947.html
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/shells/bash/patches/patch-builtins_ulimit.def

> On Thu, 31 Oct 2013 11:33:07 +0000
> Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
>
>> In the absence of other suggestions I think I'll just turn posixlocks
>> into -K (but note the incompatibility in the manual).
>
> Done, with some additional documentation for ulimit.
>
> @@ -1893,7 +1897,7 @@ enditem()
>  findex(ulimit)
>  cindex(resource limits)
>  cindex(limits, resource)
> -item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
> +item(tt(ulimit) [ [ tt(-SHacdfikKlmnpqrstvwx) | tt(-N) var(resource) [ var(limit) ] ... ])(

Thanks. I've missed usage line.

>  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 one of the values `tt(unlimited)', which removes the limit on the
> @@ -1924,9 +1928,13 @@ sitem(tt(-c))(512-byte blocks on the size of core dumps.)
>  sitem(tt(-d))(Kilobytes on the size of the data segment.)
>  sitem(tt(-f))(512-byte blocks on the size of files written.)
>  sitem(tt(-i))(The number of pending signals.)
> +sitem(tt(-k))(Maximum number of kqueues allocated.)
> +sitem(tt(-K))(Maximum number of POSIX locks per user.  Note this is
> +tt(-k) in some other shells.)
>  sitem(tt(-l))(Kilobytes on the size of locked-in memory.)
>  sitem(tt(-m))(Kilobytes on the size of physical memory.)
>  sitem(tt(-n))(open file descriptors.)
> +sitem(tt(-p))(Maximum number of pseudo-terminals.)
>  sitem(tt(-q))(Bytes in POSIX message queues.)
>  sitem(tt(-s))(Kilobytes on the size of the stack.)
>  sitem(tt(-t))(CPU seconds to be used.)

Not consitent with the wording for other options.

---
 Doc/Zsh/builtins.yo      |  9 ++++++++-
 Src/Builtins/rlimits.awk |  4 ++++
 Src/Builtins/rlimits.c   | 39 +++++++++++++++++++++++++++++++++++++++
 configure.ac             |  4 ++++
 4 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6f33c02..7927232 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1003,15 +1003,19 @@ sitem(tt(cputime))(Maximum CPU seconds per process.)
 sitem(tt(datasize))(Maximum data size (including stack) for each process.)
 sitem(tt(descriptors))(Maximum value for a file descriptor.)
 sitem(tt(filesize))(Largest single file allowed.)
+sitem(tt(kqueues))(Maximum number of kqueues allocated.)
 sitem(tt(maxproc))(Maximum number of processes.)
 sitem(tt(maxpthreads))(Maximum number of threads per process.)
 sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.)
 sitem(tt(memoryuse))(Maximum resident set size.)
 sitem(tt(msgqueue))(Maximum number of bytes in POSIX message queues.)
+sitem(tt(posixlocks))(Maximum number of POSIX advisory locks.)
+sitem(tt(pseudoterminals))(Maximum number of pseudo-terminals.)
 sitem(tt(resident))(Maximum resident set size.)
 sitem(tt(sigpending))(Maximum number of pending signals.)
 sitem(tt(sockbufsize))(Maximum size of all socket buffers.)
 sitem(tt(stacksize))(Maximum stack size for each process.)
+sitem(tt(swapsize))(Maximum amount of swap used.)
 sitem(tt(vmemorysize))(Maximum amount of virtual memory.)
 endsitem()
 
@@ -1893,7 +1897,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfiklmnpqrstvwx) | tt(-N) var(resource) [ 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 one of the values `tt(unlimited)', which removes the limit on the
@@ -1924,9 +1928,11 @@ sitem(tt(-c))(512-byte blocks on the size of core dumps.)
 sitem(tt(-d))(Kilobytes on the size of the data segment.)
 sitem(tt(-f))(512-byte blocks on the size of files written.)
 sitem(tt(-i))(The number of pending signals.)
+sitem(tt(-k))(The number of kqueues allocated.)
 sitem(tt(-l))(Kilobytes on the size of locked-in memory.)
 sitem(tt(-m))(Kilobytes on the size of physical memory.)
 sitem(tt(-n))(open file descriptors.)
+sitem(tt(-p))(The number of pseudo-terminals.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
 sitem(tt(-t))(CPU seconds to be used.)
@@ -1934,6 +1940,7 @@ sitem(tt(-r))(The number of simultaneous threads available to the user.)
 sitem(tt(-u))(The number of processes available to the user.)
 sitem(tt(-v))(Kilobytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
+sitem(tt(-w))(Kilobytes on the size of swapped out memory.)
 sitem(tt(-x))(The number of locks on files.)
 endsitem()
 
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index bf91481..b5a25fd 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -55,6 +55,10 @@ BEGIN {limidx = 0}
 	    if (limnam == "NICE") { msg[limnum] = "Nnice" }
 	    if (limnam == "RTPRIO") { msg[limnum] = "Nrt_priority" }
 	    if (limnam == "RTTIME") { msg[limnum] = "Urt_time" }
+	    if (limnam == "POSIXLOCKS") { msg[limnum] = "Nposixlocks" }
+	    if (limnam == "NPTS")    { msg[limnum] = "Npseudoterminals" }
+	    if (limnam == "SWAP")    { msg[limnum] = "Mswapsize" }
+	    if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" }
         }
     }
 }
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index eedfa96..e48a1d3 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -32,6 +32,10 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
 
+#ifdef RLIMIT_POSIXLOCKS
+#  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
+#endif
+
 enum {
     ZLIMTYPE_MEMORY,
     ZLIMTYPE_NUMBER,
@@ -386,6 +390,26 @@ printulimit(char *nam, int lim, int hard, int head)
 	    printf("-r: max rt priority                 ");
 	break;
 # endif /* HAVE_RLIMIT_RTPRIO */
+# ifdef HAVE_RLIMIT_NPTS
+    case RLIMIT_NPTS:
+	if (head)
+	    printf("-p: pseudo-terminals                ");
+	break;
+# endif /* HAVE_RLIMIT_NPTS */
+# ifdef HAVE_RLIMIT_SWAP
+    case RLIMIT_SWAP:
+	if (head)
+	    printf("-w: swap size (kbytes)              ");
+	if (limit != RLIM_INFINITY)
+	    limit /= 1024;
+	break;
+# endif /* HAVE_RLIMIT_SWAP */
+# ifdef HAVE_RLIMIT_KQUEUES
+    case RLIMIT_KQUEUES:
+	if (head)
+	    printf("-k: kqueues                         ");
+	break;
+# endif /* HAVE_RLIMIT_KQUEUES */
     default:
 	if (head)
 	    printf("-N %2d:                              ", lim);
@@ -844,6 +868,21 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_RTPRIO;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_NPTS
+		case 'p':
+		    res = RLIMIT_NPTS;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_SWAP
+		case 'w':
+		    res = RLIMIT_SWAP;
+		    break;
+# endif
+# ifdef HAVE_RLIMIT_KQUEUES
+		case 'k':
+		    res = RLIMIT_KQUEUES;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);
diff --git a/configure.ac b/configure.ac
index c3093f2..32872be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1812,6 +1812,10 @@ zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
 zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
 zsh_LIMIT_PRESENT(RLIMIT_NICE)
 zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
+zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_NPTS)
+zsh_LIMIT_PRESENT(RLIMIT_SWAP)
+zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
 
 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])



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