{"id":4540,"date":"2022-12-20T18:08:59","date_gmt":"2022-12-20T21:08:59","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/core-man5\/"},"modified":"2022-12-20T18:08:59","modified_gmt":"2022-12-20T21:08:59","slug":"core-man5","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/core-man5\/","title":{"rendered":"CORE (man5)"},"content":{"rendered":"<h1 align=\"center\">CORE<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">core \u2212 core dump file<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The default action of certain signals is to cause a process to terminate and produce a <i>core dump file<\/i>, a file containing an image of the process\u2019s memory at the time of termination. This image can be used in a debugger (e.g., <b>gdb<\/b>(1)) 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 <b>signal<\/b>(7).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A process can set its soft <b>RLIMIT_CORE<\/b> resource limit to place an upper limit on the size of the core dump file that will be produced if it receives a &#8220;core dump&#8221; signal; see <b>getrlimit<\/b>(2) for details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">There are various circumstances in which a core dump file is not produced:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The process does not have permission to write the core file. (By default, the core file is called <i>core<\/i> or <i>core.pid<\/i>, where <i>pid<\/i> 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 not writable, 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).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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 file.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The directory in which the core dump file is to be created does not exist.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The <b>RLIMIT_CORE<\/b> (core file size) or <b>RLIMIT_FSIZE<\/b> (file size) resource limits for the process are set to zero; see <b>getrlimit<\/b>(2) and the documentation of the shell\u2019s <i>ulimit<\/i> command (<i>limit<\/i> in <b>csh<\/b>(1)).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The binary being executed by the process does not have read permission enabled. (This is a security measure to ensure that an executable whose contents are not readable does not produce a\u2014possibly readable\u2014core dump containing an image of the executable.)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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 <b>capabilities<\/b>(7)). (However, see the description of the <b>prctl<\/b>(2) <b>PR_SET_DUMPABLE<\/b> operation, and the description of the <i>\/proc\/sys\/fs\/suid_dumpable<\/i> file in <b>proc<\/b>(5).)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p><i>\/proc\/sys\/kernel\/core_pattern<\/i> is empty and <i>\/proc\/sys\/kernel\/core_uses_pid<\/i> contains the value 0. (These files are described below.) Note that if <i>\/proc\/sys\/kernel\/core_pattern<\/i> is empty and <i>\/proc\/sys\/kernel\/core_uses_pid<\/i> contains the value 1, core dump files will have names of the form <i>.pid<\/i>, and such files are hidden unless one uses the <b>ls<\/b>(1) <i>\u2212a<\/i> option.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>(Since Linux 3.7) The kernel was configured without the <b>CONFIG_COREDUMP<\/b> option.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">In addition, a core dump may exclude part of the address space of the process if the <b>madvise<\/b>(2) <b>MADV_DONTDUMP<\/b> flag was employed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">On systems that employ <b>systemd<\/b>(1) as the <i>init<\/i> framework, core dumps may instead be placed in a location determined by <b>systemd<\/b>(1). See below for further details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Naming of core dump files<\/b> <br \/> By default, a core dump file is named <i>core<\/i>, but the <i>\/proc\/sys\/kernel\/core_pattern<\/i> 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:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">%%<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p style=\"margin-top: 1em\">A single % character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%c<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Core file size soft resource limit of crashing process (since Linux 2.6.24).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%d<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Dump mode\u2014same as value returned by <b>prctl<\/b>(2) <b>PR_GET_DUMPABLE<\/b> (since Linux 3.7).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%e<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>The process or thread\u2019s <i>comm<\/i> value, which typically is the same as the executable filename (without path prefix, and truncated to a maximum of 15 characters), but may have been modified to be something different; see the discussion of <i>\/proc\/[pid]\/comm<\/i> and <i>\/proc\/[pid]\/task\/[tid]\/comm<\/i> in <b>proc<\/b>(5).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%E<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Pathname of executable, with slashes (&#8216;\/&#8217;) replaced by exclamation marks (&#8216;!&#8217;) (since Linux 3.0).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%g<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Numeric real GID of dumped process.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%h<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Hostname (same as <i>nodename<\/i> returned by <b>uname<\/b>(2)).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%i<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>TID of thread that triggered core dump, as seen in the PID namespace in which the thread resides (since Linux 3.18).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%I<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>TID of thread that triggered core dump, as seen in the initial PID namespace (since Linux 3.18).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%p<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>PID of dumped process, as seen in the PID namespace in which the process resides.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%P<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>PID of dumped process, as seen in the initial PID namespace (since Linux 3.12).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%s<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Number of signal causing dump.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%t<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Time of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"3%\">\n<p>%u<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"77%\">\n<p>Numeric real UID of dumped process.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">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 &#8216;\/&#8217; 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 &#8220;core&#8221;. For backward compatibility, if <i>\/proc\/sys\/kernel\/core_pattern<\/i> does not include <i>%p<\/i> and <i>\/proc\/sys\/kernel\/core_uses_pid<\/i> (see below) is nonzero, then .PID will be appended to the core filename.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Paths are interpreted according to the settings that are active for the crashing process. That means the crashing process\u2019s mount namespace (see <b>mount_namespaces<\/b>(7)), its current working directory (found via <b>getcwd<\/b>(2)), and its root directory (see <b>chroot<\/b>(2)).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since version 2.4, Linux has also provided a more primitive method of controlling the name of the core dump file. If the <i>\/proc\/sys\/kernel\/core_uses_pid<\/i> file contains the value 0, then a core dump file is simply named <i>core<\/i>. If this file contains a nonzero value, then the core dump file includes the process ID in a name of the form <i>core.PID<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since Linux 3.6, if <i>\/proc\/sys\/fs\/suid_dumpable<\/i> is set to 2 (&#8220;suidsafe&#8221;), the pattern must be either an absolute pathname (starting with a leading &#8216;\/&#8217; character) or a pipe, as defined below.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Piping core dumps to a program<\/b> <br \/> Since kernel 2.6.19, Linux supports an alternate syntax for the <i>\/proc\/sys\/kernel\/core_pattern<\/i> file. If the first character of this file is a pipe symbol (<b>|<\/b>), then the remainder of the line is interpreted as the command-line for a user-space program (or script) that is to be executed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since kernel 5.3.0, the pipe template is split on spaces into an argument list <i>before<\/i> the template parameters are expanded. In earlier kernels, the template parameters are expanded first and the resulting string is split on spaces into an argument list. This means that in earlier kernels executable names added by the <i>%e<\/i> and <i>%E<\/i> template parameters could get split into multiple arguments. So the core dump handler needs to put the executable names as the last argument and ensure it joins all parts of the executable name using spaces. Executable names with multiple spaces in them are not correctly represented in earlier kernels, meaning that the core dump handler needs to use mechanisms to find the executable name.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Instead of being written to a file, the core dump is given as standard input to the program. Note the following points:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p style=\"margin-top: 1em\">The program must be specified using an absolute pathname (or a pathname relative to the root directory, <i>\/<\/i>), and must immediately follow the \u2019|\u2019 character.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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 <i>%p<\/i> in an argument.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The process created to run the program runs as user and group <i>root<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>Running as <i>root<\/i> 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 <i>\/proc\/[pid]<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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 <i>%P<\/i> to find the right <i>\/proc\/[pid]<\/i> directory and probe\/enter the crashing process\u2019s namespaces if needed.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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 <i>%P<\/i> specifier to change to the location of the dumping process via <i>\/proc\/[pid]\/cwd<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>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).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"85%\">\n<p>The <b>RLIMIT_CORE<\/b> limit is not enforced for core dumps that are piped to a program via this mechanism.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>\/proc\/sys\/kernel\/core_pipe_limit<\/b> <br \/> 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\u2019s <i>\/proc\/[pid]<\/i> directory. 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\u2019s <i>\/proc\/[pid]<\/i> files prematurely. This in turn creates the possibility that a misbehaving collecting program can block the reaping of a crashed process by simply never exiting.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Since Linux 2.6.32, the <i>\/proc\/sys\/kernel\/core_pipe_limit<\/i> 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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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 <i>\/proc\/<crashing-PID><\/i>). The default value for this file is 0.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Controlling which mappings are written to the core dump<\/b> <br \/> Since kernel 2.6.23, the Linux-specific <i>\/proc\/[pid]\/coredump_filter<\/i> 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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The value in the file is a bit mask of memory mapping types (see <b>mmap<\/b>(2)). 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:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"8%\">\n<p style=\"margin-top: 1em\">bit 0<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"52%\">\n<p style=\"margin-top: 1em\">Dump anonymous private mappings.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"8%\">\n<p>bit 1<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"52%\">\n<p>Dump anonymous shared mappings.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"8%\">\n<p>bit 2<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"52%\">\n<p>Dump file-backed private mappings.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"8%\">\n<p>bit 3<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"52%\">\n<p>Dump file-backed shared mappings.<\/p>\n<\/td>\n<td width=\"20%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\">bit 4 (since Linux 2.6.24)<\/p>\n<p style=\"margin-left:28%;\">Dump ELF headers.<\/p>\n<p style=\"margin-left:17%;\">bit 5 (since Linux 2.6.28)<\/p>\n<p style=\"margin-left:28%;\">Dump private huge pages.<\/p>\n<p style=\"margin-left:17%;\">bit 6 (since Linux 2.6.28)<\/p>\n<p style=\"margin-left:28%;\">Dump shared huge pages.<\/p>\n<p style=\"margin-left:17%;\">bit 7 (since Linux 4.4)<\/p>\n<p style=\"margin-left:28%;\">Dump private DAX pages.<\/p>\n<p style=\"margin-left:17%;\">bit 8 (since Linux 4.4)<\/p>\n<p style=\"margin-left:28%;\">Dump shared DAX pages.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">By default, the following bits are set: 0, 1, 4 (if the <b>CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS<\/b> kernel configuration option is enabled), and 5. This default can be modified at boot time using the <i>coredump_filter<\/i> boot option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The value of this file is displayed in hexadecimal. (The default value is thus displayed as 33.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Memory-mapped I\/O pages such as frame buffer are never dumped, and virtual DSO (<b>vdso<\/b>(7)) pages are always dumped, regardless of the <i>coredump_filter<\/i> value.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">A child process created via <b>fork<\/b>(2) inherits its parent\u2019s <i>coredump_filter<\/i> value; the <i>coredump_filter<\/i> value is preserved across an <b>execve<\/b>(2).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It can be useful to set <i>coredump_filter<\/i> in the parent shell before running a program, for example:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ <b>echo 0x7 > \/proc\/self\/coredump_filter<\/b> <br \/> $ <b>.\/some_program<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This file is provided only if the kernel was built with the <b>CONFIG_ELF_CORE<\/b> configuration option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Core dumps and systemd<\/b> <br \/> On systems using the <b>systemd<\/b>(1) <i>init<\/i> framework, core dumps may be placed in a location determined by <b>systemd<\/b>(1). To do this, <b>systemd<\/b>(1) employs the <i>core_pattern<\/i> feature that allows piping core dumps to a program. One can verify this by checking whether core dumps are being piped to the <b>systemd\u2212coredump<\/b>(8) program:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ <b>cat \/proc\/sys\/kernel\/core_pattern<\/b> <br \/> |\/usr\/lib\/systemd\/systemd\u2212coredump %P %u %g %s %t %c %e<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In this case, core dumps will be placed in the location configured for <b>systemd\u2212coredump<\/b>(8), typically as <b>lz4<\/b>(1) compressed files in the directory <i>\/var\/lib\/systemd\/coredump\/<\/i>. One can list the core dumps that have been recorded by <b>systemd\u2212coredump<\/b>(8) using <b>coredumpctl<\/b>(1):<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$ <b>coredumpctl list | tail -5<\/b> <br \/> Wed 2017-10-11 22:25:30 CEST 2748 1000 1000 3 present \/usr\/bin\/sleep <br \/> Thu 2017-10-12 06:29:10 CEST 2716 1000 1000 3 present \/usr\/bin\/sleep <br \/> Thu 2017-10-12 06:30:50 CEST 2767 1000 1000 3 present \/usr\/bin\/sleep <br \/> Thu 2017-10-12 06:37:40 CEST 2918 1000 1000 3 present \/usr\/bin\/cat <br \/> Thu 2017-10-12 08:13:07 CEST 2955 1000 1000 3 present \/usr\/bin\/cat<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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 <b>coredumpctl<\/b>(1) allow a specified coredump file to be pulled from the <b>systemd<\/b>(1) location into a specified file. For example, to extract the core dump for PID 2955 shown above to a file named <i>core<\/i> in the current directory, one could use:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ <b>coredumpctl dump 2955 \u2212o core<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For more extensive details, see the <b>coredumpctl<\/b>(1) manual page.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To (persistently) disable the <b>systemd<\/b>(1) mechanism that archives core dumps, restoring to something more like traditional Linux behavior, one can set an override for the <b>systemd<\/b>(1) mechanism, using something like:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"># <b>echo &#8220;kernel.core_pattern=core.%p&#8221; >  <br \/> \/etc\/sysctl.d\/50\u2212coredump.conf<\/b> <br \/> # <b>\/lib\/systemd\/systemd\u2212sysctl<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">It is also possible to temporarily (i.e., until the next reboot) change the <i>core_pattern<\/i> setting using a command such as the following (which causes the names of core dump files to include the executable name as well as the number of the signal which triggered the core dump):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"># <b>sysctl \u2212w kernel.core_pattern=&#8221;%e\u2212%s.core&#8221;<\/b><\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>gdb<\/b>(1) <i>gcore<\/i> command can be used to obtain a core dump of a running process.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">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 <b>CLONE_VM<\/b> flag of <b>clone<\/b>(2)) 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 <i>%p<\/i> specification in <i>\/proc\/sys\/kernel\/core_pattern<\/i>. (This is primarily useful when employing the obsolete LinuxThreads implementation, where each thread of a process has a different PID.)<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The program below can be used to demonstrate the use of the pipe syntax in the <i>\/proc\/sys\/kernel\/core_pattern<\/i> file. The following shell session demonstrates the use of this program (compiled to create an executable named <i>core_pattern_pipe_test<\/i>):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ <b>cc \u2212o core_pattern_pipe_test core_pattern_pipe_test.c<\/b> <br \/> $ <b>su<\/b> <br \/> Password: <br \/> # <b>echo &#8220;|$PWD\/core_pattern_pipe_test %p UID=%u GID=%g sig=%s&#8221; >  <br \/> \/proc\/sys\/kernel\/core_pattern<\/b> <br \/> # <b>exit<\/b> <br \/> $ <b>sleep 100 <br \/> ^<\/b> # type control-backslash <br \/> Quit (core dumped) <br \/> $ <b>cat core.info<\/b> <br \/> argc=5 <br \/> argc[0]=<\/home\/mtk\/core_pattern_pipe_test> <br \/> argc[1]=<20575> <br \/> argc[2]=<UID=1000> <br \/> argc[3]=<GID=100> <br \/> argc[4]=<sig=3> <br \/> Total bytes in core dump: 282624<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Program source<\/b> <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var core_pattern_pipe_test.c *\/<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">#define _GNU_SOURCE <br \/> #include <sys\/stat.h> <br \/> #include <fcntl.h> <br \/> #include <limits.h> #include <stdio.h> <br \/> #include <stdlib.h> <br \/> #include <unistd.h><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">#define BUF_SIZE 1024<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <br \/> main(int argc, char *argv[]) <br \/> { <br \/> ssize_t nread, tot; <br \/> char buf[BUF_SIZE]; <br \/> FILE *fp; <br \/> char cwd[PATH_MAX];<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">\/* Change our current working directory to that of the <br \/> crashing process *\/<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">snprintf(cwd, PATH_MAX, &#8220;\/proc\/%s\/cwd&#8221;, argv[1]); <br \/> chdir(cwd);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">\/* Write output to file &#8220;core.info&#8221; in that directory *\/<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">fp = fopen(&#8220;core.info&#8221;, &#8220;w+&#8221;); <br \/> if (fp == NULL) <br \/> exit(EXIT_FAILURE);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">\/* Display command\u2212line arguments given to core_pattern <br \/> pipe program *\/<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">fprintf(fp, &#8220;argc=%dn&#8221;, argc); <br \/> for (int j = 0; j < argc; j++) <br \/> fprintf(fp, &#8220;argc[%d]=<%s>n&#8221;, j, argv[j]);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">\/* Count bytes in standard input (the core dump) *\/<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">tot = 0; <br \/> while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0) <br \/> tot += nread; <br \/> fprintf(fp, &#8220;Total bytes in core dump: %zdn&#8221;, tot);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">fclose(fp); <br \/> exit(EXIT_SUCCESS); <br \/> }<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>bash<\/b>(1), <b>coredumpctl<\/b>(1), <b>gdb<\/b>(1), <b>getrlimit<\/b>(2), <b>mmap<\/b>(2), <b>prctl<\/b>(2), <b>sigaction<\/b>(2), <b>elf<\/b>(5), <b>proc<\/b>(5), <b>pthreads<\/b>(7), <b>signal<\/b>(7), <b>systemd\u2212coredump<\/b>(8)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  core \u2212 core dump file <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[959],"tags":[961,1500,1291],"class_list":["post-4540","post","type-post","status-publish","format-standard","hentry","category-5-formatos-de-ficheros","tag-961","tag-core","tag-man5"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4540"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4540\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}