summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2020-08-19 02:57:54 +0000
committerbrian m. carlson <sandals@crustytoothpaste.net>2020-08-19 02:57:54 +0000
commit45d2ddc541dcbad5a17133a9b6c65a954de4820a (patch)
treed130ab9e11cf1b1755d6bc9fd8d034e98ad18e47
parent396a0293bddd1967b967d4be51b9132dde639687 (diff)
zshenv: set a stack size limit
In recent versions of Linux, the value set for RLIMIT_STACK also affects ARG_MAX. If this value is unlimited, ARG_MAX is set to 4611686018427387903, which is much larger than the available amount of memory in the system. That means that a program trying to malloc that amount of memory will fail. pgrep falls into this category. To help out these programs, let's set the stack size to 64 MiB, which is quite generous, which in turn causes ARG_MAX to be 16 MiB. This is a sane and reasonable amount of memory a program might want to malloc, so various programs will work as normal. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
-rw-r--r--zsh/zshenv4
1 files changed, 3 insertions, 1 deletions
diff --git a/zsh/zshenv b/zsh/zshenv
index 381268f..ea1704f 100644
--- a/zsh/zshenv
+++ b/zsh/zshenv
@@ -128,9 +128,11 @@ source_if_present () {
[[ -f $fn ]] && source "$fn"
}
-# Set up some limits.
+# Set up some limits. The stack size affects ARG_MAX, so set a generous stack
+# size that still results in a sane ARG_MAX value.
unlimit
limit core 0
+limit stack 65536
# Set up umask. If we have private groups, use 002; otherwise, use 022.
if [[ $(id -u -n) = $(id -g -n) ]]; then