From: Stefan Neudorf <BM-2cXppXU4T67w7j6NCir9T1WdzBHmFgBnLj@bitmessage.ch>
To: zsh-workers@zsh.org
Subject: PATCH: add more ulimit extensions from BSDs
Date: Wed, 30 Oct 2013 02:33:18 +0100 [thread overview]
Message-ID: <20131030.86li1bwnj5@bitmessage.ch> (raw)
On FreeBSD 10, ulimit -a shows at the end
-N 11: unlimited
-N 12: unlimited
-N 13: unlimited
while sh's ulimit -a describes them as
pseudo-terminals (-p) unlimited
swap limit (kbytes, -w) unlimited
kqueues (-k) unlimited
and DragonFly only has
posixlocks (-k) unlimited
---
Doc/Zsh/builtins.yo | 4 ++++
Src/Builtins/rlimits.awk | 4 ++++
Src/Builtins/rlimits.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 4 ++++
4 files changed, 58 insertions(+)
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6f33c02..54455a4 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1013,6 +1013,10 @@ 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(vmemorysize))(Maximum amount of virtual memory.)
+sitem(tt(posixlocks))(Maximum number of POSIX locks per user.)
+sitem(tt(pseudoterminals))(Maximum number of pseudo-terminals.)
+sitem(tt(swapuse))(Maximum amount of swap used.)
+sitem(tt(kqueues))(Maximum number of kqueues allocated.)
endsitem()
Which of these resource limits are available depends on the system.
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index bf91481..ccee49e 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] = "Mswapuse" }
+ if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" }
}
}
}
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index eedfa96..3095109 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -386,6 +386,32 @@ printulimit(char *nam, int lim, int hard, int head)
printf("-r: max rt priority ");
break;
# endif /* HAVE_RLIMIT_RTPRIO */
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+ case RLIMIT_POSIXLOCKS:
+ if (head)
+ printf("-k: posixlocks ");
+ break;
+# endif /* HAVE_RLIMIT_POSIXLOCKS */
+# 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 limit (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 +870,26 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
res = RLIMIT_RTPRIO;
break;
# endif
+# ifdef HAVE_RLIMIT_POSIXLOCKS
+ case 'k':
+ res = RLIMIT_POSIXLOCKS;
+ 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.])
next reply other threads:[~2013-10-30 2:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 1:33 Stefan Neudorf [this message]
2013-10-30 10:59 ` Peter Stephenson
2013-10-30 15:29 ` Bart Schaefer
2013-10-31 11:33 ` Peter Stephenson
2013-10-31 20:10 ` Peter Stephenson
2013-10-31 23:09 ` PATCH: " Stefan Neudorf
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=20131030.86li1bwnj5@bitmessage.ch \
--to=bm-2cxppxu4t67w7j6ncir9t1wdzbhmfgbnlj@bitmessage.ch \
--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).