Section: Linux Programmer's Manual (5)
Return to Main Contents
core - core dump file
The default action of certain signals is to cause a process to terminate
and produce a
core dump file,
a disk file containing an image of the process's memory at
the time of termination.
This image can be used in a debugger (e.g.,
to inspect the state of the program at the time that it terminated.
A list of the signals which cause a process to dump core can be found in
A process can set its soft
resource limit to place an upper limit on the size of the core dump file
that will be produced if it receives a "core dump" signal; see
There are various circumstances in which a core dump file is
The process does not have permission to write the core file.
(By default, the core file is called
is the ID of the process that dumped core,
and is created in the current working directory.
See below for details on naming.)
Writing the core file fails if the directory in which
it is to be created is nonwritable,
or if a file with the same name exists and
is not writable
or is not a regular file
(e.g., it is a directory or a symbolic link).
A (writable, regular) file with the same name as would be used for the
core dump already exists, but there is more than one hard link to that
The filesystem where the core dump file would be created is full;
or has run out of inodes; or is mounted read-only;
or the user has reached their quota for the filesystem.
The directory in which the core dump file is to be created does
(core file size) or
(file size) resource limits for the process are set to zero; see
and the documentation of the shell's
The binary being executed by the process does not have read
The process is executing a set-user-ID (set-group-ID) program
that is owned by a user (group) other than the real user (group)
ID of the process,
or the process is executing a program that has file capabilities (see
(However, see the description of the
operation, and the description of the
is empty and
contains the value 0.
(These files are described below.)
Note that if
is empty and
contains the value 1,
core dump files will have names of the form
and such files are hidden unless one uses the
(Since Linux 3.7)
The kernel was configured without the
a core dump may exclude part of the address space of the process if the
flag was employed.
On systems that employ
framework, core dumps may instead be placed in a location determined by
See below for further details.
Naming of core dump files
By default, a core dump file is named
file (since Linux 2.6 and 2.4.21)
can be set to define a template that is used to name core dump files.
The template can contain % specifiers which are substituted
by the following values when a core file is created:
a single % character
core file size soft resource limit of crashing process (since Linux 2.6.24)
dump mode---same as value returned by
(since Linux 3.7)
executable filename (without path prefix)
pathname of executable,
with slashes ('/') replaced by exclamation marks ('!')
(since Linux 3.0).
(numeric) real GID of dumped process
hostname (same as nodename returned by uname(2))
TID of thread that triggered core dump,
as seen in the PID namespace in which the thread resides
(since Linux 3.18)
TID of thread that triggered core dump, as seen in the initial PID namespace
(since Linux 3.18)
PID of dumped process,
as seen in the PID namespace in which the process resides
PID of dumped process, as seen in the initial PID namespace
(since Linux 3.12)
number of signal causing dump
time of dump, expressed as seconds since the
Epoch, 1970-01-01 00:00:00 +0000 (UTC)
(numeric) real UID of dumped process
A single % at the end of the template is dropped from the
core filename, as is the combination of a % followed by any
character other than those listed above.
All other characters in the template become a literal
part of the core filename.
The template may include '/' characters, which are interpreted
as delimiters for directory names.
The maximum size of the resulting core filename is 128 bytes (64 bytes
in kernels before 2.6.19).
The default value in this file is "core".
For backward compatibility, if
does not include
is nonzero, then .PID will be appended to the core filename.
Paths are interpreted according to the settings that are active for the
That means the crashing process's mount namespace (see
its current working directory (found via
and its root directory (see
Since version 2.4, Linux has also provided
a more primitive method of controlling
the name of the core dump file.
file contains the value 0, then a core dump file is simply named
If this file contains a nonzero value, then the core dump file includes
the process ID in a name of the form
Since Linux 3.6,
is set to 2 ("suidsafe"), the pattern must be either an absolute pathname
(starting with a leading '/' character) or a pipe, as defined below.
Piping core dumps to a program
Since kernel 2.6.19, Linux supports an alternate syntax for the
If the first character of this file is a pipe symbol (|),
then the remainder of the line is interpreted as the command-line for
a user-space program (or script) that is to be executed.
Instead of being written to a disk file, the core dump is given as
standard input to the program.
Note the following points:
The program must be specified using an absolute pathname (or a
pathname relative to the root directory, /),
and must immediately follow the '|' character.
The command-line arguments can include any of
the % specifiers listed above.
For example, to pass the PID of the process that is being dumped, specify
in an argument.
The process created to run the program runs as user and group
does not confer any exceptional security bypasses.
Namely, LSMs (e.g., SELinux) are still active and may prevent the handler
from accessing details about the crashed process via
The program pathname is interpreted with respect to the initial mount namespace
as it is always executed there.
It is not affected by the settings
(e.g., root directory, mount namespace, current working directory)
of the crashing process.
The process runs in the initial namespaces
(PID, mount, user, and so on)
and not in the namespaces of the crashing process.
One can utilize specifiers such as
to find the right
directory and probe/enter the crashing process's namespaces if needed.
The process starts with its current working directory
as the root directory.
If desired, it is possible change to the working directory of
the dumping process by employing the value provided by the
specifier to change to the location of the dumping process via
Command-line arguments can be supplied to the
program (since Linux 2.6.24),
delimited by white space (up to a total line length of 128 bytes).
limit is not enforced for core dumps that are piped to a program
via this mechanism.
When collecting core dumps via a pipe to a user-space program,
it can be useful for the collecting program to gather data about
the crashing process from that process's
In order to do this safely,
the kernel must wait for the program collecting the core dump to exit,
so as not to remove the crashing process's
This in turn creates the
possibility that a misbehaving collecting program can block
the reaping of a crashed process by simply never exiting.
Since Linux 2.6.32,
can be used to defend against this possibility.
The value in this file defines how many concurrent crashing
processes may be piped to user-space programs in parallel.
If this value is exceeded, then those crashing processes above this value
are noted in the kernel log and their core dumps are skipped.
A value of 0 in this file is special.
It indicates that unlimited processes may be captured in parallel,
but that no waiting will take place (i.e., the collecting
program is not guaranteed access to
The default value for this file is 0.
Controlling which mappings are written to the core dump
Since kernel 2.6.23, the Linux-specific
file can be used to control which memory segments are written to the
core dump file in the event that a core dump is performed for the
process with the corresponding process ID.
The value in the file is a bit mask of memory mapping types (see
If a bit is set in the mask, then memory mappings of the
corresponding type are dumped; otherwise they are not dumped.
The bits in this file have the following meanings:
- bit 0
Dump anonymous private mappings.
- bit 1
Dump anonymous shared mappings.
- bit 2
Dump file-backed private mappings.
- bit 3
Dump file-backed shared mappings.
- bit 4 (since Linux 2.6.24)
Dump ELF headers.
- bit 5 (since Linux 2.6.28)
Dump private huge pages.
- bit 6 (since Linux 2.6.28)
Dump shared huge pages.
- bit 7 (since Linux 4.4)
Dump private DAX pages.
- bit 8 (since Linux 4.4)
Dump shared DAX pages.
By default, the following bits are set: 0, 1, 4 (if the
kernel configuration option is enabled), and 5.
This default can be modified at boot time using the
The value of this file is displayed in hexadecimal.
(The default value is thus displayed as 33.)
Memory-mapped I/O pages such as frame buffer are never dumped, and
virtual DSO pages are always dumped, regardless of the
A child process created via
inherits its parent's
value is preserved across an
It can be useful to set
in the parent shell before running a program, for example:
$ echo 0x7 > /proc/self/coredump_filter
This file is provided only if the kernel was built with the
Core dumps and systemd
On systems using the
framework, core dumps may be placed in a location determined by
To do this,
feature that allows piping core dumps to a program.
One can verify this by checking whether core dumps are being piped to the
$ cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %e
In this case, core dumps will be placed in the location configured for
compressed files in the directory
One can list the core dumps that have been recorded by
$ coredumpctl list | tail -5
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
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
allow a specified coredump file to be pulled from the
location into a specified file.
For example, to extract the core dump for PID 2955 shown above to a file named
in the current directory, one could use:
$ coredumpctl dump 2955 -o core
For more extensive details, see the
To disable the
mechanism that archives core dumps, restoring to something more like
traditional Linux behavior, one can set an override for the
mechanism, using something like:
# echo "kernel.core_pattern=core.%p" > /etc/sysctl.d/50-coredump.conf
command can be used to obtain a core dump of a running process.
In Linux versions up to and including 2.6.27,
if a multithreaded process (or, more precisely, a process that
shares its memory with another process by being created with the
dumps core, then the process ID is always appended to the core filename,
unless the process ID was already included elsewhere in the
filename via a
(This is primarily useful when employing the obsolete
where each thread of a process has a different PID.)
The program below can be used to demonstrate the use of the
pipe syntax in the
The following shell session demonstrates the use of this program
(compiled to create an executable named
$ cc -o core_pattern_pipe_test core_pattern_pipe_test.c
# echo "|$PWD/core_pattern_pipe_test %p UID=%u GID=%g sig=%s" > \
$ sleep 100
^\ # type control-backslash
Quit (core dumped)
$ cat core.info
Total bytes in core dump: 282624
/* core_pattern_pipe_test.c */
#define BUF_SIZE 1024
main(int argc, char *argv)
int tot, j;
/* Change our current working directory to that of the
crashing process */
snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv);
/* Write output to file "core.info" in that directory */
fp = fopen("core.info", "w+");
if (fp == NULL)
/* Display command-line arguments given to core_pattern
pipe program */
fprintf(fp, "argc=%d\n", argc);
for (j = 0; j < argc; j++)
fprintf(fp, "argc[%d]=<%s>\n", j, argv[j]);
/* Count bytes in standard input (the core dump) */
tot = 0;
while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
tot += nread;
fprintf(fp, "Total bytes in core dump: %d\n", tot);
This page is part of release 4.15 of the Linux
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
- Naming of core dump files
- Piping core dumps to a program
- Controlling which mappings are written to the core dump
- Core dumps and systemd
- Program source
- SEE ALSO
This document was created by
using the manual pages.
Time: 08:24:04 GMT, September 26, 2018