zsh-workers
 help / color / mirror / code / Atom feed
* tgoto issue in zsh-5.0.0
@ 2012-08-16 12:04 Thomas Klausner
  2012-08-16 13:07 ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2012-08-16 12:04 UTC (permalink / raw)
  To: zsh-workers

Hi!

zsh-5.0.0 has two prototypes for tgoto (in case they lack in the
system headers) which do not have the same signature (except on AIX).

The first one is in Src/prototypes.h:
#if !(defined(USES_TERMCAP_H) || defined(USES_TERM_H))
/*
 * These prototypes are only used where we don't have the
 * headers.  In some cases they need tweaking.
 * TBD: we'd much prefer to get hold of the header where
 * these are defined.
 */
#ifdef _AIX
#define TC_CONST const
#else
#define TC_CONST
#endif
...
extern char *tgoto _((TC_CONST char *cm, int destcol, int destline));
...
#undef TC_CONST
#endif


The second one is in Src/zsh_system.h:
#ifdef TGOTO_PROTO_MISSING
char *tgoto(const char *cap, int col, int row);
#endif

This causes a compile error due to conflicting prototypes (on at least
NetBSD-5.99.40/amd64, an older development version of NetBSD-6; it's
fine on another newer snapshot).
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: tgoto issue in zsh-5.0.0
  2012-08-16 12:04 tgoto issue in zsh-5.0.0 Thomas Klausner
@ 2012-08-16 13:07 ` Peter Stephenson
  2012-08-16 13:20   ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2012-08-16 13:07 UTC (permalink / raw)
  To: zsh-workers

On Thu, 16 Aug 2012 14:04:21 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> zsh-5.0.0 has two prototypes for tgoto (in case they lack in the
> system headers) which do not have the same signature (except on AIX).

I suppose that's what you get for having too many header
files... presumably the older one is redundant.

Index: Src/prototypes.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prototypes.h,v
retrieving revision 1.7
diff -p -u -r1.7 prototypes.h
--- Src/prototypes.h	3 May 2011 12:03:47 -0000	1.7
+++ Src/prototypes.h	16 Aug 2012 13:06:18 -0000
@@ -49,11 +49,18 @@ extern int tgetent _((char *bp, TC_CONST
 extern int tgetnum _((char *id));
 extern int tgetflag _((char *id));
 extern char *tgetstr _((char *id, char **area));
-extern char *tgoto _((TC_CONST char *cm, int destcol, int destline));
 extern int tputs _((TC_CONST char *cp, int affcnt, int (*outc) (int)));
 #undef TC_CONST
 #endif
 
+/*
+ * Some systems that do have termcap headers nonetheless don't
+ * declare tgoto, so we detect if that is missing separately.
+ */
+#ifdef TGOTO_PROTO_MISSING
+char *tgoto(const char *cap, int col, int row);
+#endif
+
 /* MISSING PROTOTYPES FOR VARIOUS OPERATING SYSTEMS */
 
 #if defined(__hpux) && defined(_HPUX_SOURCE) && !defined(_XPG4_EXTENDED)
Index: Src/zsh_system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh_system.h,v
retrieving revision 1.2
diff -p -u -r1.2 zsh_system.h
--- Src/zsh_system.h	21 Jun 2012 08:45:03 -0000	1.2
+++ Src/zsh_system.h	16 Aug 2012 13:06:18 -0000
@@ -874,7 +874,3 @@ extern short ospeed;
 #  endif
 # endif
 #endif
-
-#ifdef TGOTO_PROTO_MISSING
-char *tgoto(const char *cap, int col, int row);
-#endif

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: tgoto issue in zsh-5.0.0
  2012-08-16 13:07 ` Peter Stephenson
@ 2012-08-16 13:20   ` Thomas Klausner
  2012-08-16 13:25     ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2012-08-16 13:20 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Thu, Aug 16, 2012 at 02:07:34PM +0100, Peter Stephenson wrote:
> I suppose that's what you get for having too many header
> files... presumably the older one is redundant.

Unsurprisingly, your patch works. Thank you.

Will this be in the next release or do I need to file a bug report somewhere?
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: tgoto issue in zsh-5.0.0
  2012-08-16 13:20   ` Thomas Klausner
@ 2012-08-16 13:25     ` Peter Stephenson
  2012-08-16 14:25       ` pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0] Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2012-08-16 13:25 UTC (permalink / raw)
  To: Thomas Klausner; +Cc: zsh-workers

On Thu, 16 Aug 2012 15:20:54 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> On Thu, Aug 16, 2012 at 02:07:34PM +0100, Peter Stephenson wrote:
> > I suppose that's what you get for having too many header
> > files... presumably the older one is redundant.
> 
> Unsurprisingly, your patch works. Thank you.

It'll automatically be included in 5.0.1.  When depends on how many bugs
get fixed over the next few weeks, but a fairly early maintenance release for
a new major version seems like a sensible idea... but not too early, since
the reports are only trickling at the moment.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 25+ messages in thread

* pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-16 13:25     ` Peter Stephenson
@ 2012-08-16 14:25       ` Thomas Klausner
  2012-08-16 19:18         ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2012-08-16 14:25 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

On Thu, Aug 16, 2012 at 02:25:17PM +0100, Peter Stephenson wrote:
> It'll automatically be included in 5.0.1.

Great!

> When depends on how many bugs
> get fixed over the next few weeks, but a fairly early maintenance release for
> a new major version seems like a sensible idea... but not too early, since
> the reports are only trickling at the moment.

Ok, so if you have time, here are two patches that are currently in
pkgsrc for zsh.

Parts are for Interix and have been in pkgsrc for a long time. The
initial bug report was
	http://gnats.NetBSD.org/cgi-bin/query-pr-single.pl?number=25946
I can't test on Interix, so I can only forward them.

The other one is for NetBSD when using clang. If you need equivalent
patches for configure.{ac,in}, I can provide those as well.

Let me know if you have questions about them.

Thanks,
 Thomas

[-- Attachment #2: patch-ab --]
[-- Type: text/plain, Size: 551 bytes --]

$NetBSD: patch-ab,v 1.14 2012/08/16 14:19:35 wiz Exp $

Make this package build on Interix.  Patches provided by Hiramatsu
Yoshifumi in PR pkg/25946.

--- Src/zsh.h.orig	2011-05-16 15:49:11.000000000 +0000
+++ Src/zsh.h
@@ -2122,6 +2122,7 @@ struct ttyinfo {
 #endif
 };
 
+#ifndef __INTERIX
 /* defines for whether tabs expand to spaces */
 #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
 #define SGTTYFLAG       shttyinfo.tio.c_oflag
@@ -2139,6 +2140,7 @@ struct ttyinfo {
 #   endif
 #  endif
 # endif
+#endif
 
 /* flags for termflags */
 

[-- Attachment #3: patch-ac --]
[-- Type: text/plain, Size: 1671 bytes --]

$NetBSD: patch-ac,v 1.24 2012/08/16 14:19:35 wiz Exp $

All chunks:
Make this package build on Interix.  Patches provided by Hiramatsu
Yoshifumi in PR pkg/25946.
Last chunk only:
Don't force -Wl,--whole-archive for NetBSD, it breaks the build with
clang, which doesn't have a reason to disable it again.

--- configure.orig	2011-05-16 15:49:15.000000000 +0000
+++ configure
@@ -11443,6 +11443,10 @@ $as_echo "$zsh_cv_sys_elf" >&6; }
         DLLD="${DLLD=$CC}"
         DLLDARG=""
       ;;
+      *interix*)
+        DLLD="${DLLD=$CC}"
+        DLLDARG=""
+      ;;
       * )
 	DLLD="${DLLD=ld}"
 	DLLDARG=""
@@ -11453,6 +11457,7 @@ $as_echo "$zsh_cv_sys_elf" >&6; }
     case "$host_os" in
       hpux*)   DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
       darwin*) DLCFLAGS="${DLCFLAGS=-fno-common}" ;;
+      interix*) DLCFLAGS="${DLCFLAGS=}" ;;
       *)       DLCFLAGS="${DLCFLAGS=-fPIC}" ;;
     esac
   else
@@ -11467,10 +11472,9 @@ $as_echo "$zsh_cv_sys_elf" >&6; }
   fi
   case "$host_os" in
     osf*) DLLDFLAGS="${DLLDFLAGS=-shared -expect_unresolved '*'}" ;;
-    *freebsd*|linux*|irix*|gnu*|dragonfly*) DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
+    *freebsd*|*netbsd*|linux*|irix*|gnu*|interix*|dragonfly*) DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
     sunos*)       DLLDFLAGS="${DLLDFLAGS=-assert nodefinitions}" ;;
     sysv4*|esix*) DLLDFLAGS="${DLLDFLAGS=-G $ldflags}" ;;
-    netbsd*)      DLLDFLAGS="${DLLDFLAGS=${DLLDARG}-x -shared --whole-archive}" ;;
     aix*)         DLLDFLAGS="${DLLDFLAGS=-G -bexpall -lc}" ;;
     solaris*|sysv4*|esix*) DLLDFLAGS="${DLLDFLAGS=-G}" ;;
     darwin*)      DLLDFLAGS="${DLLDFLAGS=-bundle -flat_namespace -undefined suppress}" ;;

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-16 14:25       ` pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0] Thomas Klausner
@ 2012-08-16 19:18         ` Peter Stephenson
  2012-08-17  8:11           ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2012-08-16 19:18 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Thu, 16 Aug 2012 16:25:04 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> Ok, so if you have time, here are two patches that are currently in
> pkgsrc for zsh.
> 
> Parts are for Interix and have been in pkgsrc for a long time. The
> initial bug report was
> 	http://gnats.NetBSD.org/cgi-bin/query-pr-single.pl?number=25946
> I can't test on Interix, so I can only forward them.
> 
> The other one is for NetBSD when using clang. If you need equivalent
> patches for configure.{ac,in}, I can provide those as well.
> 
> Let me know if you have questions about them.

I've backported it to configure.ac, so should all present and correct.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-16 19:18         ` Peter Stephenson
@ 2012-08-17  8:11           ` Thomas Klausner
  2012-08-17  9:38             ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2012-08-17  8:11 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Thu, Aug 16, 2012 at 08:18:48PM +0100, Peter Stephenson wrote:
> I've backported it to configure.ac, so should all present and correct.

Thank you very much.

One more issue: Recently NetBSD added support for per-user thread (not
process) limits. zsh doesn't seem to support this.

# sh
# ulimit -a
time          (-t seconds    ) unlimited
file          (-f blocks     ) unlimited
data          (-d kbytes     ) 262144
stack         (-s kbytes     ) 4096
coredump      (-c blocks     ) unlimited
memory        (-m kbytes     ) 12186708
locked memory (-l kbytes     ) 4062236
thread        (-r threads    ) 160
process       (-p processes  ) 160
nofiles       (-n descriptors) 128
vmemory       (-v kbytes     ) unlimited
sbsize        (-b bytes      ) unlimited

# zsh
# ulimit -a
-t: cpu time (seconds)         unlimited
-f: file size (blocks)         unlimited
-d: data seg size (kbytes)     262144
-s: stack size (kbytes)        4096
-c: core file size (blocks)    unlimited
-m: resident set size (kbytes) 12186708
-l: locked-in-memory size (kb) 4062236
-u: processes                  160
-n: file descriptors           128
-N  9: socket buffer size (kb) unlimited
-v: virtual memory size (kb)   unlimited
-N 11:                         160

getrlimit(2) describes it as:
     RLIMIT_NTHR     The maximum number of simultaneous threads (Lightweight
                     Processes) for this user id.  Kernel threads and the
                     first thread of each process are not counted against this
                     limit.

See http://netbsd.gw.com/cgi-bin/man-cgi?getrlimit++NetBSD-current for
the complete man page.

Please let me know if you need more information about this.

Thanks,
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-17  8:11           ` Thomas Klausner
@ 2012-08-17  9:38             ` Peter Stephenson
  2012-08-17 10:50               ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2012-08-17  9:38 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Fri, 17 Aug 2012 10:11:09 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> One more issue: Recently NetBSD added support for per-user thread (not
> process) limits. zsh doesn't seem to support this.

It should be as simple as this, though I can't test it directly.

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.139
diff -p -u -r1.139 configure.ac
--- configure.ac	21 Jun 2012 08:45:02 -0000	1.139
+++ configure.ac	17 Aug 2012 09:36:54 -0000
@@ -1799,6 +1799,7 @@ zsh_LIMIT_PRESENT(RLIMIT_AS)
 zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
 zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
 zsh_LIMIT_PRESENT(RLIMIT_NPROC)
+zsh_LIMIT_PRESENT(RLIMIT_NTHR)
 zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
 zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
 zsh_LIMIT_PRESENT(RLIMIT_RSS)
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.139
diff -p -u -r1.139 builtins.yo
--- Doc/Zsh/builtins.yo	16 Aug 2012 14:00:11 -0000	1.139
+++ Doc/Zsh/builtins.yo	17 Aug 2012 09:36:54 -0000
@@ -1738,7 +1738,7 @@ enditem()
 findex(ulimit)
 cindex(resource limits)
 cindex(limits, resource)
-item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])(
+item(tt(ulimit) [ [ tt(-SHacdfilmnpqrstvx) | 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
@@ -1759,6 +1759,9 @@ When looping over multiple resources, th
 it detects a badly formed argument.  However, if it fails to set a limit
 for some other reason it will continue trying to set the remaining limits.
 
+Not all the following resources are supported on all systems.  Running
+tt(ulimit -a) will show which are supported.
+
 startsitem()
 sitem(tt(-a))(Lists all of the current resource limits.)
 sitem(tt(-c))(512-byte blocks on the size of core dumps.)
@@ -1771,7 +1774,8 @@ sitem(tt(-n))(open file descriptors.)
 sitem(tt(-q))(Bytes in POSIX message queues.)
 sitem(tt(-s))(K-bytes on the size of the stack.)
 sitem(tt(-t))(CPU seconds to be used.)
-sitem(tt(-u))(processes available to the user.)
+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))(K-bytes on the size of virtual memory.  On some systems this
 refers to the limit called `address space'.)
 sitem(tt(-x))(The number of locks on files.)
Index: Src/Builtins/rlimits.awk
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.awk,v
retrieving revision 1.9
diff -p -u -r1.9 rlimits.awk
--- Src/Builtins/rlimits.awk	19 Jun 2011 00:10:34 -0000	1.9
+++ Src/Builtins/rlimits.awk	17 Aug 2012 09:36:54 -0000
@@ -42,6 +42,7 @@ BEGIN {limidx = 0}
 	    if (limnam == "MEMLOCK") { msg[limnum] = "Mmemorylocked" }
 	    if (limnam == "NOFILE")  { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "NPROC")   { msg[limnum] = "Nmaxproc" }
+	    if (limnam == "NTHR")    { msg[limnum] = "Nmaxthr" }
 	    if (limnam == "OFILE")   { msg[limnum] = "Ndescriptors" }
 	    if (limnam == "PTHREAD") { msg[limnum] = "Nmaxpthreads" }
 	    if (limnam == "RSS")     { msg[limnum] = "Mresident" }
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.25
diff -p -u -r1.25 rlimits.c
--- Src/Builtins/rlimits.c	31 Oct 2011 09:48:59 -0000	1.25
+++ Src/Builtins/rlimits.c	17 Aug 2012 09:36:54 -0000
@@ -314,6 +314,12 @@ printulimit(char *nam, int lim, int hard
 	    printf("-u: processes                  ");
 	break;
 # endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_NTHR
+    case RLIMIT_NTHR:
+	if (head)
+	    printf("-r: threads                    ");
+	break;
+#endif /* HAVE_RLIMIT_NTHR */
 # if defined(HAVE_RLIMIT_VMEM) && (!defined(HAVE_RLIMIT_RSS) || !defined(RLIMIT_VMEM_IS_RSS))
     case RLIMIT_VMEM:
 	if (head)
@@ -791,6 +797,11 @@ bin_ulimit(char *name, char **argv, UNUS
 		    res = RLIMIT_NOFILE;
 		    break;
 # endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_NTHR
+		case 'r':
+		    res = RLIMIT_NTHR;
+		    break;
+# endif /* HAVE_RLIMIT_NTHR */
 # ifdef HAVE_RLIMIT_NPROC
 		case 'u':
 		    res = RLIMIT_NPROC;

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-17  9:38             ` Peter Stephenson
@ 2012-08-17 10:50               ` Thomas Klausner
  2012-08-17 11:35                 ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2012-08-17 10:50 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Fri, Aug 17, 2012 at 10:38:03AM +0100, Peter Stephenson wrote:
> It should be as simple as this, though I can't test it directly.

Works fine.
# zsh
# ulimit -a
-t: cpu time (seconds)         unlimited
-f: file size (blocks)         unlimited
-d: data seg size (kbytes)     262144
-s: stack size (kbytes)        4096
-c: core file size (blocks)    unlimited
-m: resident set size (kbytes) 12186708
-l: locked-in-memory size (kb) 4062236
-u: processes                  160
-n: file descriptors           128
-N  9: socket buffer size (kb) unlimited
-v: virtual memory size (kb)   unlimited
-r: threads                    160

Thank you!

What's the "-N  9" part, should that be support explicitly as well?

Let me know when I start being annoying :)
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-17 10:50               ` Thomas Klausner
@ 2012-08-17 11:35                 ` Peter Stephenson
  2012-08-17 12:16                   ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2012-08-17 11:35 UTC (permalink / raw)
  To: zsh-workers

On Fri, 17 Aug 2012 12:50:19 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> What's the "-N  9" part, should that be support explicitly as well?

Ah, I noticed that but didn't see it on your list from sh --- now I look
more closely, that's -b, so that should be added too.  We support the
resource, just not the option letter.  It's done as bytes, not
kilobytes, so I changed that, too.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.140
diff -p -u -r1.140 builtins.yo
--- Doc/Zsh/builtins.yo	17 Aug 2012 11:12:35 -0000	1.140
+++ Doc/Zsh/builtins.yo	17 Aug 2012 11:34:10 -0000
@@ -1764,6 +1764,7 @@ tt(ulimit -a) will show which are suppor
 
 startsitem()
 sitem(tt(-a))(Lists all of the current resource limits.)
+sitem(tt(-b))(Socket buffer size in bytes LPAR()N.B. not kilobytes+RPAR())
 sitem(tt(-c))(512-byte blocks on the size of core dumps.)
 sitem(tt(-d))(K-bytes on the size of the data segment.)
 sitem(tt(-f))(512-byte blocks on the size of files written.)
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.26
diff -p -u -r1.26 rlimits.c
--- Src/Builtins/rlimits.c	17 Aug 2012 11:12:35 -0000	1.26
+++ Src/Builtins/rlimits.c	17 Aug 2012 11:34:10 -0000
@@ -365,9 +365,7 @@ printulimit(char *nam, int lim, int hard
 # ifdef HAVE_RLIMIT_SBSIZE
     case RLIMIT_SBSIZE:
 	if (head)
-	    printf("-N %2d: socket buffer size (kb) ", RLIMIT_SBSIZE);
-	if (limit != RLIM_INFINITY)
-	    limit /= 1024;
+	    printf("-b: socket buffer size (bytes)", RLIMIT_SBSIZE);
 	break;
 # endif /* HAVE_RLIMIT_SBSIZE */
 # ifdef HAVE_RLIMIT_PTHREAD
@@ -782,16 +780,21 @@ bin_ulimit(char *name, char **argv, UNUS
 		case 'c':
 		    res = RLIMIT_CORE;
 		    break;
-# ifdef HAVE_RLIMIT_RSS
-		case 'm':
-		    res = RLIMIT_RSS;
+# ifdef HAVE_RLIMIT_SBSIZE
+		case 'b':
+		    res = RLIMIT_SBSIZE;
 		    break;
-# endif /* HAVE_RLIMIT_RSS */
+# endif /* HAVE_RLIMIT_SBSIZE */
 # ifdef HAVE_RLIMIT_MEMLOCK
 		case 'l':
 		    res = RLIMIT_MEMLOCK;
 		    break;
 # endif /* HAVE_RLIMIT_MEMLOCK */
+# ifdef HAVE_RLIMIT_RSS
+		case 'm':
+		    res = RLIMIT_RSS;
+		    break;
+# endif /* HAVE_RLIMIT_RSS */
 # ifdef HAVE_RLIMIT_NOFILE
 		case 'n':
 		    res = RLIMIT_NOFILE;

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-17 11:35                 ` Peter Stephenson
@ 2012-08-17 12:16                   ` Thomas Klausner
  2012-08-17 13:27                     ` Peter Stephenson
  2014-06-24 14:37                     ` ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh] Thomas Klausner
  0 siblings, 2 replies; 25+ messages in thread
From: Thomas Klausner @ 2012-08-17 12:16 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Fri, Aug 17, 2012 at 12:35:35PM +0100, Peter Stephenson wrote:
> Ah, I noticed that but didn't see it on your list from sh --- now I look
> more closely, that's -b, so that should be added too.  We support the
> resource, just not the option letter.  It's done as bytes, not
> kilobytes, so I changed that, too.

Looks fine, except for a missing space in the -b line:
# ulimit -a
-t: cpu time (seconds)         unlimited
-f: file size (blocks)         unlimited
-d: data seg size (kbytes)     262144
-s: stack size (kbytes)        4096
-c: core file size (blocks)    unlimited
-m: resident set size (kbytes) 12186708
-l: locked-in-memory size (kb) 4062236
-u: processes                  160
-n: file descriptors           128
-b: socket buffer size (bytes)unlimited
-v: virtual memory size (kb)   unlimited
-r: threads                    160

I've added all these patches to pkgsrc, thanks again.

I have a packaging issue as well.
When grepping for "bin/zsh" on the source, there are two kinds of matches:

Functions/Example/zless:#!/bin/zsh -f
Functions/Example/cat:#!/bin/zsh -f
Functions/Misc/zed:#!/bin/zsh
Functions/Misc/run-help:#!/bin/zsh
Functions/Misc/zcalc:#!/bin/zsh -i
Functions/Misc/checkmail:#!/bin/zsh
Functions/Misc/sticky-note:#!/bin/zsh -fi
Functions/Misc/zkbd:#!/bin/zsh -f
Functions/Calendar/calendar_add:#!/bin/zsh
Test/ztst.zsh:#!/bin/zsh -f
Test/runtests.zsh:#!/bin/zsh -f

Util/reporter:#!/usr/local/bin/zsh
Misc/globtests.ksh:#!/usr/local/bin/zsh -f
Misc/globtests:#!/usr/local/bin/zsh -f

The installation directory with pkgsrc is ${PREFIX}, usually /usr/pkg,
which is why pkgsrc replaces these to point to ${PREFIX}/bin/zsh. I
wonder if you see it as worth your time to fix the path in these files
to ${PREFIX}/bin/zsh (expanded, of course) during the build?

 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0]
  2012-08-17 12:16                   ` Thomas Klausner
@ 2012-08-17 13:27                     ` Peter Stephenson
  2014-06-24 14:37                     ` ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh] Thomas Klausner
  1 sibling, 0 replies; 25+ messages in thread
From: Peter Stephenson @ 2012-08-17 13:27 UTC (permalink / raw)
  To: zsh-workers

On Fri, 17 Aug 2012 14:16:06 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> Looks fine, except for a missing space in the -b line:

I've since then tweaked the output to be more consistent, so it always
says kbytes rather than sometimes kb, and adjusted the fomatting
consistently with that.

> The installation directory with pkgsrc is ${PREFIX}, usually /usr/pkg,
> which is why pkgsrc replaces these to point to ${PREFIX}/bin/zsh. I
> wonder if you see it as worth your time to fix the path in these files
> to ${PREFIX}/bin/zsh (expanded, of course) during the build?

That probably ought to be done.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 25+ messages in thread

* ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2012-08-17 12:16                   ` Thomas Klausner
  2012-08-17 13:27                     ` Peter Stephenson
@ 2014-06-24 14:37                     ` Thomas Klausner
  2014-06-24 15:07                       ` Peter Stephenson
  1 sibling, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2014-06-24 14:37 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Hi!

A couple of days ago I noticed that 'ulimit -a' is now different (on
NetBSD-6.99.44/x86_64 with zsh-5.0.5); see in the old mail below what
it looked like before:

-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          262144
-s: stack size (kbytes)             4096
-c: core file size (blocks)         unlimited
-m: resident set size (kbytes)      32485916
-l: locked-in-memory size (kbytes)  10828638
-u: processes                       160
-n: file descriptors                128
-b: socket buffer size (bytes)      unlimited
-v: virtual memory size (kbytes)    unlimited
-N 11:                              160

It seems "-r" was replaced with "-N", and no help string is supplied.

I've also tried zsh git head and see the same issue there.

You probably know better where to look for this.

Thanks,
 Thomas

On Fri, Aug 17, 2012 at 02:16:06PM +0200, Thomas Klausner wrote:
> On Fri, Aug 17, 2012 at 12:35:35PM +0100, Peter Stephenson wrote:
> > Ah, I noticed that but didn't see it on your list from sh --- now I look
> > more closely, that's -b, so that should be added too.  We support the
> > resource, just not the option letter.  It's done as bytes, not
> > kilobytes, so I changed that, too.
> 
> Looks fine, except for a missing space in the -b line:
> # ulimit -a
> -t: cpu time (seconds)         unlimited
> -f: file size (blocks)         unlimited
> -d: data seg size (kbytes)     262144
> -s: stack size (kbytes)        4096
> -c: core file size (blocks)    unlimited
> -m: resident set size (kbytes) 12186708
> -l: locked-in-memory size (kb) 4062236
> -u: processes                  160
> -n: file descriptors           128
> -b: socket buffer size (bytes)unlimited
> -v: virtual memory size (kb)   unlimited
> -r: threads                    160
> 
> I've added all these patches to pkgsrc, thanks again.
> 
> I have a packaging issue as well.
> When grepping for "bin/zsh" on the source, there are two kinds of matches:
> 
> Functions/Example/zless:#!/bin/zsh -f
> Functions/Example/cat:#!/bin/zsh -f
> Functions/Misc/zed:#!/bin/zsh
> Functions/Misc/run-help:#!/bin/zsh
> Functions/Misc/zcalc:#!/bin/zsh -i
> Functions/Misc/checkmail:#!/bin/zsh
> Functions/Misc/sticky-note:#!/bin/zsh -fi
> Functions/Misc/zkbd:#!/bin/zsh -f
> Functions/Calendar/calendar_add:#!/bin/zsh
> Test/ztst.zsh:#!/bin/zsh -f
> Test/runtests.zsh:#!/bin/zsh -f
> 
> Util/reporter:#!/usr/local/bin/zsh
> Misc/globtests.ksh:#!/usr/local/bin/zsh -f
> Misc/globtests:#!/usr/local/bin/zsh -f
> 
> The installation directory with pkgsrc is ${PREFIX}, usually /usr/pkg,
> which is why pkgsrc replaces these to point to ${PREFIX}/bin/zsh. I
> wonder if you see it as worth your time to fix the path in these files
> to ${PREFIX}/bin/zsh (expanded, of course) during the build?
> 
>  Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-24 14:37                     ` ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh] Thomas Klausner
@ 2014-06-24 15:07                       ` Peter Stephenson
  2014-06-24 16:11                         ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2014-06-24 15:07 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Tue, 24 Jun 2014 16:37:11 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> A couple of days ago I noticed that 'ulimit -a' is now different (on
> NetBSD-6.99.44/x86_64 with zsh-5.0.5); see in the old mail below what
> it looked like before:
> 
> -t: cpu time (seconds)              unlimited
> -f: file size (blocks)              unlimited
> -d: data seg size (kbytes)          262144
> -s: stack size (kbytes)             4096
> -c: core file size (blocks)         unlimited
> -m: resident set size (kbytes)      32485916
> -l: locked-in-memory size (kbytes)  10828638
> -u: processes                       160
> -n: file descriptors                128
> -b: socket buffer size (bytes)      unlimited
> -v: virtual memory size (kbytes)    unlimited
> -N 11:                              160
> 
> It seems "-r" was replaced with "-N", and no help string is supplied.
> 
> I've also tried zsh git head and see the same issue there.
> 
> You probably know better where to look for this.

That means it hasn't identified limit 11 as being associated with
what it thinks -r was previously associated with; because it's now
a generic limit it just blindly adds it without a help string.

Sorry, I don't have access to NetBSD so not only don't I know what the
problem is I don't even know that it *is* a problem --- it's a problem
if someone thinks -N 11 is the same as -r, in which this needs
an appropriate test; or, if -N 11 is new, if that should be associated
with some other option.

Someone who does know NetBSD will have to tell me what needs doing.

In Src/rlimits.c, the only case for handling -r is currently marked as:

# ifdef HAVE_RLIMIT_RTPRIO
    case RLIMIT_RTPRIO:
	if (head)
	    printf("-r: max rt priority                 ");
	break;
# endif /* HAVE_RLIMIT_RTPRIO */

Those definitions come from a set of tests in configure.ac loooking like

zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)

which are basically identical for all limits apart from the name ---
they basically look to see if a value for RLIMIT_RTPRIO is defined
in the headers.  The headers are presumably correct as the other limits
are there.

pws


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-24 15:07                       ` Peter Stephenson
@ 2014-06-24 16:11                         ` Thomas Klausner
  2014-06-24 16:26                           ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2014-06-24 16:11 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Tue, Jun 24, 2014 at 04:07:08PM +0100, Peter Stephenson wrote:
> On Tue, 24 Jun 2014 16:37:11 +0200
> Thomas Klausner <tk@giga.or.at> wrote:
> > A couple of days ago I noticed that 'ulimit -a' is now different (on
> > NetBSD-6.99.44/x86_64 with zsh-5.0.5); see in the old mail below what
> > it looked like before:
> > 
> > -t: cpu time (seconds)              unlimited
> > -f: file size (blocks)              unlimited
> > -d: data seg size (kbytes)          262144
> > -s: stack size (kbytes)             4096
> > -c: core file size (blocks)         unlimited
> > -m: resident set size (kbytes)      32485916
> > -l: locked-in-memory size (kbytes)  10828638
> > -u: processes                       160
> > -n: file descriptors                128
> > -b: socket buffer size (bytes)      unlimited
> > -v: virtual memory size (kbytes)    unlimited
> > -N 11:                              160
> > 
> > It seems "-r" was replaced with "-N", and no help string is supplied.
> > 
> > I've also tried zsh git head and see the same issue there.
> > 
> > You probably know better where to look for this.
> 
> That means it hasn't identified limit 11 as being associated with
> what it thinks -r was previously associated with; because it's now
> a generic limit it just blindly adds it without a help string.
> 
> Sorry, I don't have access to NetBSD so not only don't I know what the
> problem is I don't even know that it *is* a problem --- it's a problem
> if someone thinks -N 11 is the same as -r, in which this needs
> an appropriate test; or, if -N 11 is new, if that should be associated
> with some other option.
>
> Someone who does know NetBSD will have to tell me what needs doing.

So here's what ulimit -a looks like with NetBSD's /bin/sh:
time          (-t seconds    ) unlimited
file          (-f blocks     ) unlimited
data          (-d kbytes     ) 262144
stack         (-s kbytes     ) 4096
coredump      (-c blocks     ) unlimited
memory        (-m kbytes     ) 32485916
locked memory (-l kbytes     ) 10828638
thread        (-r threads    ) 160
process       (-p processes  ) 160
nofiles       (-n descriptors) 128
vmemory       (-v kbytes     ) unlimited
sbsize        (-b bytes      ) unlimited

If I raise the threads limit here to 161, the value for "-N 11" in zsh
is also 161, so it's the same limit.

Is that enough information? If not, please let me know what else you need.

Thanks,
 Thomas

> 
> In Src/rlimits.c, the only case for handling -r is currently marked as:
> 
> # ifdef HAVE_RLIMIT_RTPRIO
>     case RLIMIT_RTPRIO:
> 	if (head)
> 	    printf("-r: max rt priority                 ");
> 	break;
> # endif /* HAVE_RLIMIT_RTPRIO */
> 
> Those definitions come from a set of tests in configure.ac loooking like
> 
> zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
> 
> which are basically identical for all limits apart from the name ---
> they basically look to see if a value for RLIMIT_RTPRIO is defined
> in the headers.  The headers are presumably correct as the other limits
> are there.
> 
> pws


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-24 16:11                         ` Thomas Klausner
@ 2014-06-24 16:26                           ` Peter Stephenson
  2014-06-24 17:09                             ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2014-06-24 16:26 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Tue, 24 Jun 2014 18:11:02 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> thread        (-r threads    ) 160

> If I raise the threads limit here to 161, the value for "-N 11" in zsh
> is also 161, so it's the same limit.

I'm presuming you don't have RTPRIO (so there's no clash)?  What's the
name (enum or #defined) of the limit referred to as "threads", i.e. with
the value 11?  Should be in something like /usr/include/sys/resource.h
or something included from there.

gcc -E /usr/include/sys/resource.h | grep RLIMIT

might be enough to answer both questions.

I'm not sure we have an existing preprocessor test for NetBSD, so if we
need to disambiguate uses of -r we'll need that.

pws


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-24 16:26                           ` Peter Stephenson
@ 2014-06-24 17:09                             ` Thomas Klausner
  2014-06-25  8:26                               ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2014-06-24 17:09 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Tue, Jun 24, 2014 at 05:26:42PM +0100, Peter Stephenson wrote:
> On Tue, 24 Jun 2014 18:11:02 +0200
> Thomas Klausner <tk@giga.or.at> wrote:
> > thread        (-r threads    ) 160
> 
> > If I raise the threads limit here to 161, the value for "-N 11" in zsh
> > is also 161, so it's the same limit.
> 
> I'm presuming you don't have RTPRIO (so there's no clash)?  What's the
> name (enum or #defined) of the limit referred to as "threads", i.e. with
> the value 11?  Should be in something like /usr/include/sys/resource.h
> or something included from there.
> 
> gcc -E /usr/include/sys/resource.h | grep RLIMIT
> 
> might be enough to answer both questions.

The gcc statement, for some reason, doesn't work, but:

./sys/resource.h:#define        RLIMIT_NTHR     11              /* number of threads */

# grep -r RTPRIO /usr/include
#

> I'm not sure we have an existing preprocessor test for NetBSD, so if we
> need to disambiguate uses of -r we'll need that.

"uname -s" is "NetBSD".

Let me know what else I can provide to help here.

Thanks,
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-24 17:09                             ` Thomas Klausner
@ 2014-06-25  8:26                               ` Peter Stephenson
  2014-06-25  8:36                                 ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2014-06-25  8:26 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Tue, 24 Jun 2014 19:09:08 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> On Tue, Jun 24, 2014 at 05:26:42PM +0100, Peter Stephenson wrote:
> > On Tue, 24 Jun 2014 18:11:02 +0200
> > Thomas Klausner <tk@giga.or.at> wrote:
> > > thread        (-r threads    ) 160
> > 
> > > If I raise the threads limit here to 161, the value for "-N 11" in zsh
> > > is also 161, so it's the same limit.
> > 
> > I'm presuming you don't have RTPRIO (so there's no clash)?  What's the
> > name (enum or #defined) of the limit referred to as "threads", i.e. with
> > the value 11?  Should be in something like /usr/include/sys/resource.h
> > or something included from there.
> > 
> > gcc -E /usr/include/sys/resource.h | grep RLIMIT
> > 
> > might be enough to answer both questions.
> 
> The gcc statement, for some reason, doesn't work, but:
> 
> ./sys/resource.h:#define        RLIMIT_NTHR     11              /* number of threads */
> 
> # grep -r RTPRIO /usr/include
> #

That's supposed to be covered by -T for RLIMIT_PTHREAD, but the way
NetBSD sets up its limits this doesn't work, and there appears to be a
case missing in the handler.  It was moved by zsh-workers/31936
(http://www.zsh.org/mla/workers/2013/msg00970.html) to avoid the clash
with other meanings of -r, which seems reasonable given the possible
confusions, although we could provide backward compatibility where
RTPRIO doesn't exist.

diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 0bcafda..a9eb328 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -32,12 +32,14 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
 
-#ifdef RLIMIT_POSIXLOCKS
+#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS)
 #  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
+#  define HAVE_RLIMIT_LOCKS     1
 #endif
 
-#ifdef RLIMIT_NTHR
+#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD)
 #  define RLIMIT_PTHREAD	RLIMIT_NTHR
+#  define HAVE_RLIMIT_PTHREAD   1
 #endif
 
 enum {
@@ -876,6 +878,11 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_KQUEUES;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_PTHREAD
+		case 'T':
+		    res = RLIMIT_PTHREAD;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);
diff --git a/configure.ac b/configure.ac
index a2a6b9e..7c04c3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1836,6 +1836,7 @@ zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
 zsh_LIMIT_PRESENT(RLIMIT_NPTS)
 zsh_LIMIT_PRESENT(RLIMIT_SWAP)
 zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
+zsh_LIMIT_PRESENT(RLIMIT_NTHR)
 
 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])

-- 
Peter Stephenson <p.stephenson@samsung.com>  Principal Software Engineer
Tel: +44 (0)1223 434724                Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park, Cowley Road,
Cambridge, CB4 0DS, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25  8:26                               ` Peter Stephenson
@ 2014-06-25  8:36                                 ` Thomas Klausner
  2014-06-25 10:33                                   ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2014-06-25  8:36 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Wed, Jun 25, 2014 at 09:26:59AM +0100, Peter Stephenson wrote:
> That's supposed to be covered by -T for RLIMIT_PTHREAD, but the way
> NetBSD sets up its limits this doesn't work, and there appears to be a
> case missing in the handler.  It was moved by zsh-workers/31936
> (http://www.zsh.org/mla/workers/2013/msg00970.html) to avoid the clash
> with other meanings of -r, which seems reasonable given the possible
> confusions, although we could provide backward compatibility where
> RTPRIO doesn't exist.

Thanks for the explanation and fix. I can confirm that with:

> diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
> index 0bcafda..a9eb328 100644
> --- a/Src/Builtins/rlimits.c
> +++ b/Src/Builtins/rlimits.c
> @@ -32,12 +32,14 @@
>  
>  #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
>  
> -#ifdef RLIMIT_POSIXLOCKS
> +#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS)
>  #  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
> +#  define HAVE_RLIMIT_LOCKS     1
>  #endif
>  
> -#ifdef RLIMIT_NTHR
> +#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD)
>  #  define RLIMIT_PTHREAD	RLIMIT_NTHR
> +#  define HAVE_RLIMIT_PTHREAD   1
>  #endif
>  
>  enum {
> @@ -876,6 +878,11 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
>  		    res = RLIMIT_KQUEUES;
>  		    break;
>  # endif
> +# ifdef HAVE_RLIMIT_PTHREAD
> +		case 'T':
> +		    res = RLIMIT_PTHREAD;
> +		    break;
> +# endif
>  		default:
>  		    /* unrecognised limit */
>  		    zwarnnam(name, "bad option: -%c", *options);

I see and can use -T:
# ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          262144
-s: stack size (kbytes)             4096
-c: core file size (blocks)         unlimited
-m: resident set size (kbytes)      32485916
-l: locked-in-memory size (kbytes)  10828638
-u: processes                       160
-n: file descriptors                128
-b: socket buffer size (bytes)      unlimited
-v: virtual memory size (kbytes)    unlimited
-T: threads per process             160
# ulimit -T 161
# ulimit -a    
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          262144
-s: stack size (kbytes)             4096
-c: core file size (blocks)         unlimited
-m: resident set size (kbytes)      32485916
-l: locked-in-memory size (kbytes)  10828638
-u: processes                       160
-n: file descriptors                128
-b: socket buffer size (bytes)      unlimited
-v: virtual memory size (kbytes)    unlimited
-T: threads per process             161

The description for -T is not correct for NetBSD though. (I don't know
how this limit works on other operating systems.)
>From NetBSD's sh(1)'s ulimit section:

 -r          show or set the limit on the number of threads this
             user can have at one time

So the limit is not per-process, but for the user in total.

This part, however, is unneeded:

> diff --git a/configure.ac b/configure.ac
> index a2a6b9e..7c04c3a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1836,6 +1836,7 @@ zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS)
>  zsh_LIMIT_PRESENT(RLIMIT_NPTS)
>  zsh_LIMIT_PRESENT(RLIMIT_SWAP)
>  zsh_LIMIT_PRESENT(RLIMIT_KQUEUES)
> +zsh_LIMIT_PRESENT(RLIMIT_NTHR)
>  
>  AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
>  [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])

The check for RLIMIT_NTHR is already in that file, about 10 lines
higher.

Cheers,
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25  8:36                                 ` Thomas Klausner
@ 2014-06-25 10:33                                   ` Peter Stephenson
  2014-06-25 11:00                                     ` Thomas Klausner
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Stephenson @ 2014-06-25 10:33 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Wed, 25 Jun 2014 10:36:55 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> The description for -T is not correct for NetBSD though. (I don't know
> how this limit works on other operating systems.)
> From NetBSD's sh(1)'s ulimit section:
> 
>  -r          show or set the limit on the number of threads this
>              user can have at one time
> 
> So the limit is not per-process, but for the user in total.

That's basically how -T is documented in the zsh manual, so it may be
the description of -T from ulimit that's wrong.  If anyone can confirm
(Linux doesn't have either, it looks like NPROC is the nearest), I will
change this globally, but for now it's just for NetBSD.

I've added compatibility with sh when NTHR is present and RTPRIO isn't
--- which should be just about specific enough that the additional
compatibility more than offsets any confusion.

> The check for RLIMIT_NTHR is already in that file, about 10 lines
> higher.

Thanks, should have spotted that.

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 9905ab5..dd090d6 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1940,6 +1940,9 @@ 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(-r))(Maximum real time priority.  On some systems where this
+is not available, such as NetBSD, this has the same effect as tt(-T)
+for compatibility with tt(sh).)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
 sitem(tt(-T))(The number of simultaneous threads available to the user.)
 sitem(tt(-t))(CPU seconds to be used.)
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 0bcafda..bcf9ad8 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -32,12 +32,17 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
 
-#ifdef RLIMIT_POSIXLOCKS
+#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS)
 #  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
+#  define HAVE_RLIMIT_LOCKS     1
 #endif
 
-#ifdef RLIMIT_NTHR
+#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD)
 #  define RLIMIT_PTHREAD	RLIMIT_NTHR
+#  define HAVE_RLIMIT_PTHREAD   1
+#  define THREAD_FMT            "-T: threads                         "
+#else
+#  define THREAD_FMT            "-T: threads per process             "
 #endif
 
 enum {
@@ -373,7 +378,7 @@ printulimit(char *nam, int lim, int hard, int head)
 # ifdef HAVE_RLIMIT_PTHREAD
     case RLIMIT_PTHREAD:
 	if (head)
-	    printf("-T: threads per process             ");
+	    printf(THREAD_FMT);
 	break;
 # endif /* HAVE_RLIMIT_PTHREAD */
 # ifdef HAVE_RLIMIT_NICE
@@ -387,6 +392,14 @@ printulimit(char *nam, int lim, int hard, int head)
 	if (head)
 	    printf("-r: max rt priority                 ");
 	break;
+# else
+#  ifdef HAVE_RLIMIT_NTHR
+	/* For compatibility with sh on NetBSD */
+    case RLIMIT_NTHR:
+	if (head)
+	    printf("-r: threads                         ");
+	break;
+#  endif /* HAVE_RLIMIT_NTHR */
 # endif /* HAVE_RLIMIT_RTPRIO */
 # ifdef HAVE_RLIMIT_NPTS
     case RLIMIT_NPTS:
@@ -860,6 +873,13 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		case 'r':
 		    res = RLIMIT_RTPRIO;
 		    break;
+# else
+#  ifdef HAVE_RLIMIT_NTHR
+		    /* For compatibility with sh on NetBSD */
+		case 'r':
+		    res = RLIMIT_NTHR;
+		    break;
+#  endif /* HAVE_RLIMIT_NTHR */
 # endif
 # ifdef HAVE_RLIMIT_NPTS
 		case 'p':
@@ -876,6 +896,11 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_KQUEUES;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_PTHREAD
+		case 'T':
+		    res = RLIMIT_PTHREAD;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);


-- 
Peter Stephenson <p.stephenson@samsung.com>  Principal Software Engineer
Tel: +44 (0)1223 434724                Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park, Cowley Road,
Cambridge, CB4 0DS, UK


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25 10:33                                   ` Peter Stephenson
@ 2014-06-25 11:00                                     ` Thomas Klausner
  2014-06-25 11:11                                       ` Peter Stephenson
  0 siblings, 1 reply; 25+ messages in thread
From: Thomas Klausner @ 2014-06-25 11:00 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Wed, Jun 25, 2014 at 11:33:35AM +0100, Peter Stephenson wrote:
> I've added compatibility with sh when NTHR is present and RTPRIO isn't
> --- which should be just about specific enough that the additional
> compatibility more than offsets any confusion.

Thanks, but this version doesn't compile since:
rlimits.c: In function 'printulimit':
rlimits.c:398:5: error: duplicate case value
     case RLIMIT_NTHR:
     ^
rlimits.c:379:5: error: previously used here
     case RLIMIT_PTHREAD:
     ^
*** Error code 1

> @@ -387,6 +392,14 @@ printulimit(char *nam, int lim, int hard, int head)
>  	if (head)
>  	    printf("-r: max rt priority                 ");
>  	break;
> +# else
> +#  ifdef HAVE_RLIMIT_NTHR
> +	/* For compatibility with sh on NetBSD */
> +    case RLIMIT_NTHR:
> +	if (head)
> +	    printf("-r: threads                         ");
> +	break;
> +#  endif /* HAVE_RLIMIT_NTHR */
>  # endif /* HAVE_RLIMIT_RTPRIO */
>  # ifdef HAVE_RLIMIT_NPTS
>      case RLIMIT_NPTS:

The #else here is for RTPRIO, so we have cases for RLIMIT_NTHR and
RLIMIT_PTHREAD in the same case statement.
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25 11:00                                     ` Thomas Klausner
@ 2014-06-25 11:11                                       ` Peter Stephenson
  2014-06-25 12:18                                         ` Thomas Klausner
  2014-06-26  8:31                                         ` Daniel Shahaf
  0 siblings, 2 replies; 25+ messages in thread
From: Peter Stephenson @ 2014-06-25 11:11 UTC (permalink / raw)
  To: Thomas Klausner, zsh-workers

On Wed, 25 Jun 2014 13:00:11 +0200
Thomas Klausner <tk@giga.or.at> wrote:
> On Wed, Jun 25, 2014 at 11:33:35AM +0100, Peter Stephenson wrote:
> > I've added compatibility with sh when NTHR is present and RTPRIO isn't
> > --- which should be just about specific enough that the additional
> > compatibility more than offsets any confusion.
> 
> Thanks, but this version doesn't compile since:
> rlimits.c: In function 'printulimit':
> rlimits.c:398:5: error: duplicate case value
>      case RLIMIT_NTHR:
>      ^
> rlimits.c:379:5: error: previously used here
>      case RLIMIT_PTHREAD:
>      ^
> *** Error code 1

Right, we'll just have to output for -T only, not -r.  As -r's for
compatibility with sh and the zsh documentation mentions -T that's
probably not a problem.

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 9905ab5..dd090d6 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1940,6 +1940,9 @@ 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(-r))(Maximum real time priority.  On some systems where this
+is not available, such as NetBSD, this has the same effect as tt(-T)
+for compatibility with tt(sh).)
 sitem(tt(-s))(Kilobytes on the size of the stack.)
 sitem(tt(-T))(The number of simultaneous threads available to the user.)
 sitem(tt(-t))(CPU seconds to be used.)
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 0bcafda..1ab8710 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -32,12 +32,17 @@
 
 #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY)
 
-#ifdef RLIMIT_POSIXLOCKS
+#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS)
 #  define RLIMIT_LOCKS		RLIMIT_POSIXLOCKS
+#  define HAVE_RLIMIT_LOCKS     1
 #endif
 
-#ifdef RLIMIT_NTHR
+#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD)
 #  define RLIMIT_PTHREAD	RLIMIT_NTHR
+#  define HAVE_RLIMIT_PTHREAD   1
+#  define THREAD_FMT            "-T: threads                         "
+#else
+#  define THREAD_FMT            "-T: threads per process             "
 #endif
 
 enum {
@@ -373,7 +378,7 @@ printulimit(char *nam, int lim, int hard, int head)
 # ifdef HAVE_RLIMIT_PTHREAD
     case RLIMIT_PTHREAD:
 	if (head)
-	    printf("-T: threads per process             ");
+	    printf(THREAD_FMT);
 	break;
 # endif /* HAVE_RLIMIT_PTHREAD */
 # ifdef HAVE_RLIMIT_NICE
@@ -860,6 +865,13 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		case 'r':
 		    res = RLIMIT_RTPRIO;
 		    break;
+# else
+#  ifdef HAVE_RLIMIT_NTHR
+		    /* For compatibility with sh on NetBSD */
+		case 'r':
+		    res = RLIMIT_NTHR;
+		    break;
+#  endif /* HAVE_RLIMIT_NTHR */
 # endif
 # ifdef HAVE_RLIMIT_NPTS
 		case 'p':
@@ -876,6 +888,11 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    res = RLIMIT_KQUEUES;
 		    break;
 # endif
+# ifdef HAVE_RLIMIT_PTHREAD
+		case 'T':
+		    res = RLIMIT_PTHREAD;
+		    break;
+# endif
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", *options);


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25 11:11                                       ` Peter Stephenson
@ 2014-06-25 12:18                                         ` Thomas Klausner
  2014-06-26  8:31                                         ` Daniel Shahaf
  1 sibling, 0 replies; 25+ messages in thread
From: Thomas Klausner @ 2014-06-25 12:18 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Wed, Jun 25, 2014 at 12:11:55PM +0100, Peter Stephenson wrote:
> Right, we'll just have to output for -T only, not -r.  As -r's for
> compatibility with sh and the zsh documentation mentions -T that's
> probably not a problem.

I think this works as intended:
# ulimit -r 161
# ulimit -a                                
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          262144
-s: stack size (kbytes)             4096
-c: core file size (blocks)         unlimited
-m: resident set size (kbytes)      32485916
-l: locked-in-memory size (kbytes)  10828638
-u: processes                       160
-n: file descriptors                128
-b: socket buffer size (bytes)      unlimited
-v: virtual memory size (kbytes)    unlimited
-T: threads                         161
# ulimit -T 162
# ulimit -a    
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          262144
-s: stack size (kbytes)             4096
-c: core file size (blocks)         unlimited
-m: resident set size (kbytes)      32485916
-l: locked-in-memory size (kbytes)  10828638
-u: processes                       160
-n: file descriptors                128
-b: socket buffer size (bytes)      unlimited
-v: virtual memory size (kbytes)    unlimited
-T: threads                         162

Thank you!
 Thomas


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-25 11:11                                       ` Peter Stephenson
  2014-06-25 12:18                                         ` Thomas Klausner
@ 2014-06-26  8:31                                         ` Daniel Shahaf
  2014-06-26  9:49                                           ` Peter Stephenson
  1 sibling, 1 reply; 25+ messages in thread
From: Daniel Shahaf @ 2014-06-26  8:31 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Thomas Klausner, zsh-workers

Peter Stephenson wrote on Wed, Jun 25, 2014 at 12:11:55 +0100:
> +#  define THREAD_FMT            "-T: threads                         "
> +#else
> +#  define THREAD_FMT            "-T: threads per process             "
>  #endif
...
> +	    printf(THREAD_FMT);

It would be more robust to use

    printf("%s", THREAD_FMT);

to in case THREAD_FMT ever contains a %.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
  2014-06-26  8:31                                         ` Daniel Shahaf
@ 2014-06-26  9:49                                           ` Peter Stephenson
  0 siblings, 0 replies; 25+ messages in thread
From: Peter Stephenson @ 2014-06-26  9:49 UTC (permalink / raw)
  To: zsh-workers

On Thu, 26 Jun 2014 08:31:12 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Peter Stephenson wrote on Wed, Jun 25, 2014 at 12:11:55 +0100:
> > +#  define THREAD_FMT            "-T: threads                         "
> > +#else
> > +#  define THREAD_FMT            "-T: threads per process             "
> >  #endif
> ...
> > +	    printf(THREAD_FMT);
> 
> It would be more robust to use
> 
>     printf("%s", THREAD_FMT);
> 
> to in case THREAD_FMT ever contains a %.

Yes, it would; that's what I've committed.

pws


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2014-06-26  9:49 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 12:04 tgoto issue in zsh-5.0.0 Thomas Klausner
2012-08-16 13:07 ` Peter Stephenson
2012-08-16 13:20   ` Thomas Klausner
2012-08-16 13:25     ` Peter Stephenson
2012-08-16 14:25       ` pkgsrc patches for zsh [was Re: tgoto issue in zsh-5.0.0] Thomas Klausner
2012-08-16 19:18         ` Peter Stephenson
2012-08-17  8:11           ` Thomas Klausner
2012-08-17  9:38             ` Peter Stephenson
2012-08-17 10:50               ` Thomas Klausner
2012-08-17 11:35                 ` Peter Stephenson
2012-08-17 12:16                   ` Thomas Klausner
2012-08-17 13:27                     ` Peter Stephenson
2014-06-24 14:37                     ` ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh] Thomas Klausner
2014-06-24 15:07                       ` Peter Stephenson
2014-06-24 16:11                         ` Thomas Klausner
2014-06-24 16:26                           ` Peter Stephenson
2014-06-24 17:09                             ` Thomas Klausner
2014-06-25  8:26                               ` Peter Stephenson
2014-06-25  8:36                                 ` Thomas Klausner
2014-06-25 10:33                                   ` Peter Stephenson
2014-06-25 11:00                                     ` Thomas Klausner
2014-06-25 11:11                                       ` Peter Stephenson
2014-06-25 12:18                                         ` Thomas Klausner
2014-06-26  8:31                                         ` Daniel Shahaf
2014-06-26  9:49                                           ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).