Saturday, December 10, 2016

debugging systemd service in Raspbian 8 through core dumps

Taking notes on what I did to enable core dumps from a service running under systemd. Not sure which of these were strictly necessary, though.

Added to /etc/security/limits.conf
* soft core unlimited
* hard core unlimited

Added to /etc/sysctl.d/core.conf
kernel.core_pattern = core-%e-sig%s-user%u-group%g-pid%p-time%t
kernel.core_uses_pid = 1

fs.suid_dumpable = 2

Added to /lib/systemd/system/my-service.service [Service] -section

created world-writable dump directory
sudo mkdir -p /var/lib/coredumps
sudo chown nobody:nogroup /var/lib/coredumps
sudo chmod a+w /var/lib/coredumps/

Verified that limits are ok
grep core /proc/$(pgrep damon-process-name-here)/limits

Verified that core gets dumped
sudo kill -SIGABRT $(pgrep damon-process-name-here)
gdb /bin/my-daemon /var/lib/coredumps/core*

No comments:

Post a Comment