How can I get daemons started by init.d at boot to coredump on Ubuntu? This is what I have done so far...
echo "ulimit -c unlimited" >> /etc/profile
mkdir /corefiles/
chmod 777 /corefiles/
echo "kernel.core_pattern=/corefiles/core.%e.%u.%t" >> /etc/sysctl.conf
echo "fs.suid_dumpable=1" >> /etc/sysctl.conf
echo "kernel.core_uses_pid = 1" >> /etc/sysctl.conf
sysctl -p
This works great for everything except a daemon that is started by init.d at boot. I am running Ubuntu 10.04. I am looking for a solution that does not involve editing each daemons init.d file.
EDIT: Also, daemons started with sudo do not coredump.
Why not use Apport? It's disabled by default on non-development versions of Ubuntu, but it's still installed by default AFAIK.
/etc/profile
is executed when a user logs in for an interactive session (and even then that depends on the login method and login shell). It has no effect on daemons started at boot.Apparently (I haven't tested to confirm) core dumps start out disabled on Ubuntu 10.04. They can be enabled by setting a nonzero size limit in
/etc/security/limits.conf
. See the comments in that file and thelimits.conf
man page for more information. I think you'll want to add a line like
Programs that have elevated privileges generally don't dump core (I don't know the exact rule off the top of my head). This may affect processes launched directly through privilege elevation such as
sudo foo
; trysudo sh -c foo
instead (so that the child process starts at its final privilege level)./etc/profile
is only sourced by your login shell, not by initscripts./etc/security/limits.conf
will also only affect login sessions as well, as those limits are put in place bypam_limits.so
; from pam_limits manpage:To get the behaviour you want, you should modify the initscript and insert your
ulimit -c unlimited
command. As Dom mentioned, you could also do this by editing the lsb init-functions library.I think all of these options are need for the daemons you launch. To have the core dumps, you should add the ulimit command to the beginning of the launchers. The Launchers should use /lib/lsb/init-functions. So you may modify it as you want. I don't test anything here, so try !