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 '18 at 9:37
  • I'm not sure, that's why I asked. – Doron Behar Jul 22 '18 at 14:27

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. – Rui F Ribeiro Jul 22 '18 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. – Doron Behar Jul 22 '18 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 '18 at 15:13

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.