18

My question is probably not related to Ubuntu in particular, but since my desktop running this OS, I came to this forum.

I am trying to change the core file size using ulimit -c command as follows:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 7959
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

Changing the limitation:

$ ulimit -c unlimited

Observing the result:

$ ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 7959
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

Indeed the limit is changed. However, when I open another terminal and check the value, I still see zero value in core file size.

Questions:

  1. Are changes made using ulimit command affect only current process, i.e. in this case the bash?
  2. I launch a program from shell as a fore- or-background process. Does the ulimit change apply for new process ?
  3. How can I make that all user processes are affected with this configuration ?
1

1 Answer 1

17

ulimit is a shell builtin, and thus only affects the current shell, and processes started by that shell:

$ type ulimit
ulimit is a shell builtin

From man ulimit:

The  ulimit  utility  shall  set  or report the file-size writing limit
imposed on files written by the shell and its child processes (files of
any  size  may be read). Only a process with appropriate privileges can
increase the limit.

So, yes, child processes are affected.

To set limits permanently or for all processes, edit /etc/security/limits.conf and reboot. The examples in the manpage are fairly good. You just need to add something like:

username - core unlimited
2
  • Thanks. By manpages.ubuntu.com/manpages/bionic/man1/ulimit.1posix.html, Is ulimit also an external command besides being a bash builtin command?
    – Tim
    Commented May 28, 2018 at 16:51
  • @Tim quoting the page you linked to: "Since ulimit affects the current shell execution environment, it is always provided as a shell regular built-in."
    – muru
    Commented May 28, 2018 at 16:55

You must log in to answer this question.

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