I'm working on a large C++ project. While testing it, I frequently get a core dumped from the main process. This produces a lot of uninteresting core dumps saved within systemd and it takes useful disk space.

Is it possible under Linux running systemd to disable core-dumps from being recorded only temporarily for a certain user or a perhaps even better only in a certain tty or a certain shell session?

It seems reasonable to me that a user should have the option to disable core-dumps recordings if he/she is about to run a program that dumps a core frequently and he doesn't want to fill the disk space, without the root's intervention.

  • core-dump ? Isn't that a kernel behavior which can be turned off for whole userspace? Am I missing something? Jul 22, 2018 at 9:37
  • I'm not sure, that's why I asked. Jul 22, 2018 at 14:27

1 Answer 1


Did you try to edit /etc/profile and add a line:

ulimit -c 0

to this? If you are not root, you could tell the people to run this command by hand.

BTW: most Linux distros make a coredump limit of 0 the default, so debugging on a typical Lnux system does not work unless you type

ulimit -c unlimited

in your shell.

The ulimit command internally calls the setrlimit() syscall that sets up settings in the process that are inherited by all children. Any program may call setrlimit(), not only the shell.

Any of the children in theory may change these settings and create a new inheritance line. So make sure, that e.g. no shell is called in the middle that changes the value again. This may e.g. happen in case that a call to ulimit is in one of the startup scripts of the shell.

  • +1 for the last paragraph. Jul 22, 2018 at 11:16
  • Exactly what I was looking for, just for clarification: where ulimit gives me shell built-in command - I assume that it works per shell session and not per login session. Jul 22, 2018 at 14:35
  • 1
    It works for the shell and all it's children. As long as none of the processes changes the settings.
    – schily
    Jul 22, 2018 at 15:13
  • ulimit -c 0 does not reliably avoid coredump generation on linux. If the system is setup to pipe coredumps into a program (like systemd-coredump, etc) linux ignores the ulimit (as it is not writing a file?). The way to disable coredump generation even in that case is using prctl to set PR_SET_DUMPABLE to 0. I think systemd-coredump itself might disable disk storage with 0 ulimit, but not all crash reporting software might respect ulimit.
    – textshell
    Apr 30 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.