zsh-workers
 help / color / mirror / code / Atom feed
From: Thomas Klausner <tk@giga.or.at>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-workers@zsh.org
Subject: Re: ulimit -a: -r vs -N [was Re: pkgsrc patches for zsh]
Date: Wed, 25 Jun 2014 10:36:55 +0200	[thread overview]
Message-ID: <20140625083655.GP13765@danbala.tuwien.ac.at> (raw)
In-Reply-To: <20140625092659.3e084cc7@pwslap01u.europe.root.pri>

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


  reply	other threads:[~2014-06-25  8:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140625083655.GP13765@danbala.tuwien.ac.at \
    --to=tk@giga.or.at \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).