Enabling Daemon Coredumps on Linux

More Information

Fedora Community Portal Instructions

RedHat Knowledgebase Note

Enable coredumps in daemon start script

In the daemon startup script (/etc/init.d/mydaemon) add the following line before the definition of the "start()" method:

DAEMON_COREFILE_LIMIT="unlimited"

Enable coredumps globally

Edit the /etc/profile configuration file. Search for existing ulimit -c commands and replace with:

# Enable core files by default
ulimit -c unlimited > /dev/null 2>&1

Allow setuid programs to dump core

# The suid_dumpable control file is found in different places ...
if [ -e /proc/sys/kernel/suid_dumpable ]; then
  echo 1 > /proc/sys/kernel/suid_dumpable
else
  echo 1 > /proc/sys/fs/suid_dumpable
fi

Changing coredump location

echo /var/tmp/core > /proc/sys/kernel/core_pattern

Make above changes persistent after reboot

Add the following entries to /etc/sysctl.conf:

# Allow suid programs to dump core
fs.suid_dumpable = 1

# Dump core in /var/tmp
kernel.core_pattern = /var/tmp/core

Testing coredumps

Send the process the SIGABRT signal, it should abort and dump core:

kill -ABRT <pid>