There are two types of core dump which can take place on a linux based system.
- Application core dump
- Kernel core dump
kernel.core_pattern tunable relates to the former (application dump). It is used to control where application core dumps are saved and also how they will be named.
Application core dumps can occur, for example, when there is a memory segmentation fault.
Here is an example of the kernel.core_pattern when set in the sysctl.conf file;
<i>kernel.core_pattern = /you/define/the/path/appcore-%e-%s-%u-%g-%p-%t
The formatting placeholders used above have the following definitions;
# appcore = generic reference to what is in the file<br /> # %e = executable file name (without the path being prefixed<br /> # %s = the number of the signal which caused the application to crash out and dump it's contents<br /> # %u = the real ID which was running the dumped process<br /> # %g = the real GID which was running the dumped process<br /> # %p = the pid of the dumped process<br /> # %t = the time of the dump
The following is stolen from the core(5) man page;
<br /> <pre> <b>Naming of core dump files</b><br /> By default, a core dump file is named <i>core</i>, but the<br /> <i>/proc/sys/kernel/core_pattern file (since Linux 2.6 and 2.4.21) can<br /> be set to define a template that is used to name core dump files.<br /> The template can contain % specifiers which are substituted by the<br /> following values when a core file is created:</p> <p> %% a single % character<br /> %c core file size soft resource limit of crashing process (since<br /> Linux 2.6.24)<br /> %d dump mode—same as value returned by <a href="http://man7.org/linux/man-pages/man2/prctl.2.html">prctl(2)</a> <b>PR_GET_DUMPABLE</b><br /> (since Linux 3.7)<br /> %e executable filename (without path prefix)<br /> %E pathname of executable, with slashes ('/') replaced by<br /> exclamation marks ('!') (since Linux 3.0).<br /> %g (numeric) real GID of dumped process<br /> %h hostname (same as <i>nodename</i> returned by <a href="http://man7.org/linux/man-pages/man2/uname.2.html">uname(2)</a>)<br /> %i TID of thread that triggered core dump, as seen in the PID<br /> namespace in which the thread resides (since Linux 3.18)<br /> %I TID of thread that triggered core dump, as seen in the<br /> initial PID namespace (since Linux 3.18)<br /> %p PID of dumped process, as seen in the PID namespace in which<br /> the process resides<br /> %P PID of dumped process, as seen in the initial PID namespace<br /> (since Linux 3.12)<br /> %s number of signal causing dump<br /> %t time of dump, expressed as seconds since the Epoch,<br /> 1970-01-01 00:00:00 +0000 (UTC)<br /> %u (numeric) real UID of dumped process</p> <p> A single % at the end of the template is dropped from the core<br /> filename, as is the combination of a % followed by any character<br /> other than those listed above. All other characters in the template<br /> become a literal part of the core filename. The template may include<br /> '/' characters, which are interpreted as delimiters for directory<br /> names. The maximum size of the resulting core filename is 128 bytes<br /> (64 bytes in kernels before 2.6.19). The default value in this file<br /> is "core". For backward compatibility, if<br /> <i>/proc/sys/kernel/core_pattern</i> does not include "%p" and<br /> <i>/proc/sys/kernel/core_uses_pid</i> (see below) is nonzero, then .PID will<br /> be appended to the core filename.</p> <p> Since version 2.4, Linux has also provided a more primitive method of<br /> controlling the name of the core dump file. If the<br /> <i>/proc/sys/kernel/core_uses_pid</i> file contains the value 0, then a core<br /> dump file is simply named <i>core</i>. If this file contains a nonzero<br /> value, then the core dump file includes the process ID in a name of<br /> the form <i>core.PID</i>.</p> <p> Since Linux 3.6, if <i>/proc/sys/fs/suid_dumpable</i> is set to 2<br /> ("suidsafe"), the pattern must be either an absolute pathname<br /> (starting with a leading '/' character) or a pipe, as defined below.<br />