To get a core dump you need to do something to change the max core file size, because it’s 0 by default.

In Linux, default shell bash has a built-in command which lets you set various resource limits for the processes started by the shell, like the core file size, called ulimit. You, hence, have to change these limitations before executing any program you want.

Let’s see how it work:

sojia [~] -pigfoot- [W0] ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
pending signals (-i) 32767
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 32767
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

“core file size” line says 0 blocks. Change it by using ‘ulimit -c’:

sojia [~] -pigfoot- [W0] ulimit -c
0
sojia [~] -pigfoot- [W0] ulimit -c unlimited
sojia [~] -pigfoot- [W0] ulimit -c
unlimited

As you think, to enlarge the available FDs is to set the option of “-n”. Not exactly. It’s because only privileged user (root) can set this option. Here we go:

sojia [~] -pigfoot- [W0] ulimit -n
1024
sojia [~] -pigfoot- [W0] ulimit -n 8192
bash: ulimit: open files: cannot modify limit: Operation not permitted
sojia [~] -pigfoot- [W0] su
Password:
sojia ~ # ulimit -c
unlimited
sojia ~ # ulimit -n
1024
sojia ~ # ulimit -n 8192
sojia ~ # ulimit -n
8192
sojia ~ # exit
logout
sojia [~] -pigfoot- [W0] ulimit -n
1024

The first, we can see it encounters “Operation not permitted” as normal user. Second, coredump size is inherited. The last but the important thing is, when we terminate privileged session and return to normal user shell, the maximum number of FDs is back. You know why? Feedback please. ;-)

AS a result, if we want to change the maximum number of FDs for some program, we must execute it as root. Please keep it in mind.

Popularity: 17% [?]