2

How can I permanently change the stack size in WSL2 Ubuntu? I can temporarily change the size with:

ulimit -s unlimited

But that only lasts till the session is closed. I have tried adding these lines to /etc/security/limits.conf:

* soft stack unlimited
* hard stack unlimited

But that does not change the stack limit as reported by ulimit -a.

I can call ulimit -s unlimited in .bashrc, but that won't work for non-interactive shells.

Strangely, if I su to my own user with su user, the stack appears as unlimited! It is only when I open the shell where it appears to have some default of 8192.

2
  • Did you logout and login again after changing limits.conf? Nov 8 at 16:52
  • Indeed I have logged in and out again after changing limits.conf.
    – nograpes
    Nov 9 at 1:01

1 Answer 1

1
+100

/etc/security/limits.conf are used by pam_limits. You need to authenticate via ssh, su, sudo, for PAM and limits.conf file to be taken in consideration.

I see as alternative to set the limits in ~/.bashrc or /etc/bash.bashrc Also in those file you can export BASH_ENV to point to a file similar to bashrc for non-interactive shells.

E.g. for ~/.bashrc:

ulimit -s unlimited
export BASH_ENV=~/.bashrc-non-interactive

And in ~/.bashrc-non-interactive:

ulimit -s unlimited

For more details: Bash startup files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .