3

I was a victim of a fork bomb of my own construction, and I couldn't figure out how to stop it short of logging off. (Tools like ProcMon were too slow to get ahead of the newly started processes).

In order to keep a future one "under control", I want to reduce the maximum number of user processes in my MSYS2 (MinGW32) system from 256 down to 50.

I have these commands at the top of my .bashrc:

ulimit -S -c 0      # Don't want coredumps.
ulimit -S -u 50     # limit 50 processes
export FUNCNEST=44  # limit function recursion

and I get this terminal output:

++ ulimit -S -c 0
++ ulimit -S -u 50
bash: ulimit: max user processes: cannot modify limit: Invalid argument
++ export FUNCNEST=44
++ FUNCNEST=44

Note the first ulimit command (for core dump size) works; the second for max user processes fails.

I am a member of the administrators group. I hope that's sufficient authority, as my system does not have SU or SUDO commands, nor do I know how to logon on as (or switch to) root. There is no /etc/security/ directory for system wide limits. MSYS2 in installed on Windows XP SP3.

+ id User
uid=197614(User) gid=197121(None) groups=11(Authenticated Users),197121(None),197616(HelpLibraryUpdaters),544(Administrators),545(Users)

Can you please explain what I am doing wrong, or how to limit the number of shells being spun off?

Alternatively, can you recommend a method of stopping an in-progress fork bomb?


Here is what ulimit -a displays:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 8
stack size              (kbytes, -s) 2040
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256
virtual memory          (kbytes, -v) unlimited

Here is what ulimit -Ha displays:

+ ulimit -Ha
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
open files                      (-n) 3200
pipe size            (512 bytes, -p) 8
stack size              (kbytes, -s) unlimited
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256
virtual memory          (kbytes, -v) unlimited

Here is what ulimit -Sa displays:

+ ulimit -Sa
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 8
stack size              (kbytes, -s) 2040
cpu time               (seconds, -t) unlimited
max user processes              (-u) 256
virtual memory          (kbytes, -v) unlimited

0

You must log in to answer this question.

Browse other questions tagged .