Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Cores apparently are not dumped when the using sudo despite ulimit -c being set to unlimited. Is there any way around this?

share|improve this question

sudo will reset the core dump settings, like it does for a lot of other environment state. You can run the program via a helper that first enables core dumps and then runs the program. Create for example a wrapper /usr/local/bin/coredump, with the contents (and chmod +x):

ulimit -c unlimited
exec "$@"


sudo /usr/local/bin/coredump /your/crashing/program
share|improve this answer
I've discovered that even with ulimit -c set to unlimited that, sudo su to root still will not produce a core. – Catskul Jul 20 '11 at 21:01
Yes, I've already mentioned what sudo will reset the core dump setting. You have to do "ulimit -c unlimited" after the sudo. – Ambroz Bizjak Jul 20 '11 at 21:30
That's what I was saying. Sudoing to root using sudo su then setting the core limit to unlimited it still would not produce a core. This is no longer an issue after messing with sysctl, but despite suid_dumpable behavior being well documented, for some reason it doesn't seem to be as consistent in practice. – Catskul Jul 20 '11 at 21:40
up vote 0 down vote accepted

It seems it can be done using the -s option like:

sudo -s "ulimit -c unlimited; ./segfaultProg"

However 2 caveats:

  1. You may need to set the suid_dumpable parameter with sysctl -w kernel.suid_dumpable=2
  2. You may need to move an old core out of the way. Apparently there are special rules where it may refuse to write a core if the suid bit is set, and there's already a core there.

See the following for details:

share|improve this answer

You must log in to answer this question.

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