core.5: Adds some notes on systemd and core dumps

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-10-12 08:31:17 +02:00
parent 6c3d8859e6
commit 03c871367c
1 changed files with 92 additions and 0 deletions

View File

@ -134,6 +134,15 @@ a core dump may exclude part of the address space of the process if the
.BR madvise (2)
.B MADV_DONTDUMP
flag was employed.
.PP
On systems that employ
.BR systemd (1)
as the
.I init
framework, core dumps may instead be placed in a location determined by
.BR systemd (1).
See below for further details.
.\"
.SS Naming of core dump files
By default, a core dump file is named
.IR core ,
@ -434,6 +443,89 @@ in the parent shell before running a program, for example:
This file is provided only if the kernel was built with the
.B CONFIG_ELF_CORE
configuration option.
.\"
.SS Core dumps and systemd
On systems using the
.BR systemd (1)
.I init
framework, core dumps may be placed in a location determined by
.BR systemd (1).
To do this,
.BR systemd (1)
employs the
.I core_pattern
feature that allows piping core dumps to a file.
One can verify this by checking whether core dumps are being piped to the
.BR systemd-coredump (8)
program:
.PP
.in +4n
.EX
$ \fBcat /proc/sys/kernel/core_pattern\fP
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %e
.EE
.in
.PP
In this case, core dumps will be placed in the location configured for
.BR systemd-coredump (8),
typically as
.BR lz4 (1)
compressed files in the directory
.IR /var/lib/systemd/coredump/ .
One can list the core dumps that have been recorded by
.BR systemd-coredump (8)
using
.BR coredumpctl (1):
.PP
.in +4n
.EX
$ \fBcoredumpctl list | tail -5\fP
Wed 2017-10-11 22:25:30 CEST 2748 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:29:10 CEST 2716 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:30:50 CEST 2767 1000 1000 3 present /usr/bin/sleep
Thu 2017-10-12 06:37:40 CEST 2918 1000 1000 3 present /usr/bin/cat
Thu 2017-10-12 08:13:07 CEST 2955 1000 1000 3 present /usr/bin/cat
.EE
.in
.PP
The information shown for each core dump includes the date and time
of the dump, the PID, UID, and GID of the dumping process,
the signal number that caused the core dump,
and the pathname of the executable that was being run by the dumped process.
Various options to
.BR coredumpctl (1)
allow a specified coredump file to be pulled from the
.BR systemd (1)
location into a specified file.
For example, to extract the core dump for PID 2955 shown above to a file named
.IR core
in the current directory, one coud use:
.PP
.in +4n
.EX
$ \fBcoredumpctl dump 2955 -o core\fP
.EE
.in
.PP
For more extensive details, see the
.BR coredumpctl (1)
manual page.
.PP
To disable the
.BR systemd (1)
mechanism that archives core dumps, restoring to something more like
traditional Linux behavior, one can set an override for the
.BR systemd (1)
mechanism, using something like:
.PP
.in +2n
.EX
# echo "kernel.core_pattern=core.%p" > /etc/sysctl.d/50-coredump.conf
# /lib/systemd/systemd-sysctl
.EE
.in
.PP
.\"
.SH NOTES
The
.BR gdb (1)