Most Linux distributions ship with the pam_limits module to limit the resources that can be used by a process. You can enforce process resource limits by the user that a process runs as or by the group name a process runs as. These limits are set in /etc/security/limits.conf. To see the limits for your running shell you can run ulimit with the “-a” option:
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 63354 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 1024 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
All of the limits above are the system defaults, since I haven’t made
any changes to /etc/security/limits.conf. To view the resource limits
assigned to an arbitrary process on the system you can page the
Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes 1024 63354 processes Max open files 1024 4096 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 63354 63354 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us
There are a number of cool things you can do with resource limits, and I’ll type up my resource limits notes and post them in the near future. Rock & roll!