How to enable core dumps on UCS systems

To enable system wide core dumps:

To analyse segfaults in processes it might be of need to allow them to dump their state into a core file.

UCS >= 4.2

Beginning with UCS-4.2 several services are started via systemd, which provides a clean process environment for services. Therefore the global change described above does not affect such processes.
Instead the default for DefaultLimitCORE can be changed for all processes in the systemd configuration file /etc/systemd/system.conf.

As an alternative the limit can be set individually for each service by augmenting its .service file. Either use a command like systemctl edit cups.service to add LimitCORE=infinity to the section [Service], or create such a file manually and reload systemd wtih

install -d -m755 /etc/systemd/system/cups.service.d
cat >/etc/systemd/system/cups.service.d/override.conf <<__CONF__
[Service]
LimitCORE=infinity
__CONF__
systemctl daemon-reload

In both cases the service needs to be restarted afterwards with systemctl restart cups.service.

The configured limit can be verified by using systemctl show -p LimitCORE -p LimitCORESoft cups.service.
The limit of the currently running process can be queried by using grep core "/proc/$(systemctl show -p MainPID --value cups.service)/limits".

UCS < 4.2

To enable system wide core dumps you may use the following commands:

ulimit -c unlimited
grep -Flq 'ulimit -c unlimited' /etc/default/rcS ||
  echo "ulimit -c unlimited" >>/etc/default/rcS
ucr set 'security/limits/user/*/soft/core=unlimited' 'security/limits/user/*/hard/core=unlimited'
install -d -m2733 /var/tmp/core
cat >/etc/sysctl.d/core.conf <<__CONF__
kernel.core_pattern = /var/tmp/core/core-%e-%p-%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2
__CONF__
sysctl -q -p /etc/sysctl.d/core.conf

A reboot is needed to apply the new ulimit to all processes.

Please not that core dumps may take up a lot of disk space! You should monitor /var/tmp/core/ especially if it is held on the root file system.

To disable system wide core dumps:

To disable the system wide core dumps, use the following commands:

ulimit -c 0
grep -Flq 'ulimit -c unlimited' /etc/default/rcS &&
  sed -i "/^ulimit -c unlimited$/d" /etc/default/rcS
ucr unset 'security/limits/user/*/soft/core' 'security/limits/user/*/hard/core'
rm -f /etc/sysctl.d/core.conf
sysctl -q -w kernel.core_uses_pid=0 fs.suid_dumpable=1

A reboot it needed to apply the default ulimit to all processes.

You may also delete already created dumps:

rm -f /var/tmp/core/*
Mastodon