From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8658 invoked by alias); 25 Jun 2014 10:33:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32797 Received: (qmail 3689 invoked from network); 25 Jun 2014 10:33:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f626d000004b39-6c-53aaa57f96cd Date: Wed, 25 Jun 2014 11:33:35 +0100 From: Peter Stephenson To: Thomas Klausner , zsh-workers@zsh.org Subject: Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh] Message-id: <20140625113335.2a2675cd@pwslap01u.europe.root.pri> In-reply-to: <20140625083655.GP13765@danbala.tuwien.ac.at> References: <20120817105019.GB2428@danbala.tuwien.ac.at> <20120817123535.62ab00a1@pwslap01u.europe.root.pri> <20120817121605.GD2428@danbala.tuwien.ac.at> <20140624143711.GG13765@danbala.tuwien.ac.at> <20140624160708.6bef4d2c@pwslap01u.europe.root.pri> <20140624161102.GJ13765@danbala.tuwien.ac.at> <20140624172642.61b422e0@pwslap01u.europe.root.pri> <20140624170908.GK13765@danbala.tuwien.ac.at> <20140625092659.3e084cc7@pwslap01u.europe.root.pri> <20140625083655.GP13765@danbala.tuwien.ac.at> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOLMWRmVeSWpSXmKPExsVy+t/xa7oNS1cFGzSGWMx7vZjV4mDzQyYH Jo/e7T/YPVYd/MAUwBTFZZOSmpNZllqkb5fAlXFq3zHmgpcKFXdP/GFuYJwk2cXIySEhYCJx 53YjO4QtJnHh3nq2LkYuDiGBpYwSv1b1MEM4/UwSG2ceYgOpYhFQlZgy/w0LiM0mYCgxddNs RhBbRMBCYsbB78wgtrCAo8SE9TPBpvIK2EtMXn8GrJ5TwErixoI9TBBDt7NI7Hw5F6yZX0Bf 4urfT0wQZ9hLzLxyhhGiWVDix+R7YM3MAloSm7c1sULY8hKb17xlnsAoMAtJ2SwkZbOQlC1g ZF7FKJpamlxQnJSea6RXnJhbXJqXrpecn7uJERKYX3cwLj1mdYhRgINRiYc3gGdVsBBrYllx Ze4hRgkOZiURXsc5QCHelMTKqtSi/Pii0pzU4kOMTBycUg2Msc9OsOeJS052qVm0X35BdFmL +8oZ86I5ez53/a9h2Khi6TKNa7vAvVWtVzdrvjt0dutruzPKk3xPxugFGl8Q14q5wWdevfKV k7V8/T/l8JecW9pEUyd/87xefvfGVvXPug0aXUrqoQe1K/nWvJOVEjw9+cOpLoWL52WmnP+T bfc+xCzh84loJZbijERDLeai4kQAD4jjgioCAAA= On Wed, 25 Jun 2014 10:36:55 +0200 Thomas Klausner 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 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