]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man5/core.5
Change mtk's email address
[thirdparty/man-pages.git] / man5 / core.5
1 .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.
16 .\"
17 .\" Formatted or processed versions of this manual, if unaccompanied by
18 .\" the source, must acknowledge the copyright and authors of this work.
19 .\"
20 .TH CORE 5 2006-04-03 "Linux" "Linux Programmer's Manual"
21 .SH NAME
22 core \- core dump file
23 .SH DESCRIPTION
24 The default action of certain signals is to cause a process to terminate
25 and produce a
26 .IR "core dump file" ,
27 a disk file containing an image of the process's memory at
28 the time of termination.
29 A list of the signals which cause a process to dump core can be found in
30 .BR signal (7).
31
32 A process can set its soft
33 .BR RLIMIT_CORE
34 resource limit to place an upper limit on the size of the core dump file
35 that will be produced if it receives a "core dump" signal; see
36 .BR getrlimit (2)
37 for details.
38
39 There are various circumstances in which a core dump file is
40 not produced:
41 .IP *
42 The process does not have permission to write the core file.
43 (By default the core file is called
44 .IR core ,
45 and is created in the current working directory.
46 See below for details on naming.)
47 Writing the core file will fail if the directory in which
48 it is to be created is non-writable,
49 or if a file with the same name exists and
50 is not writable
51 or is not a regular file
52 (e.g., it is a directory or a symbolic link).
53 .IP *
54 A (writable, regular) file with the same name as would be used for the
55 core dump already exists, but there is more than one hard link to that
56 file.
57 .IP *
58 The file system where the core dump file would be created is full;
59 or has run out of inodes; or is mounted read only;
60 or the user has reached their quota for the file system.
61 .IP *
62 The directory in which the core dump file is to be created does
63 not exist.
64 .IP *
65 .B RLIMIT_CORE
66 or
67 .B RLIMIT_FSIZE
68 resource limits for a process are set to zero (see
69 .BR getrlimit (2)).
70 .IP *
71 The binary being executed by the process does not have read
72 permission enabled.
73 .IP *
74 The process is executing a set-user-ID (set-group-ID) program
75 that is owned by a user (group) other than the real user (group)
76 ID of the process.
77 (However, see the description of the
78 .BR prctl (2)
79 .B PR_SET_DUMPABLE
80 operation, and the description of the
81 .I /proc/sys/fs/suid_dumpable
82 file in
83 .BR proc (5).)
84 .SS Naming of core dump files
85 By default, a core dump file is named
86 .IR core ,
87 but the
88 .I /proc/sys/kernel/core_pattern
89 file
90 (since Linux 2.6 and 2.4.21)
91 can be set to define a template that is used to name core dump files.
92 The template can contain % specifiers which are substituted
93 by the following values when a core file is created:
94 .nf
95
96 %% A single % character
97 %p PID of dumped process
98 %u real UID of dumped process
99 %g real GID of dumped process
100 %s number of signal causing dump
101 %t time of dump (seconds since 0:00h, 1 Jan 1970)
102 %h hostname (same as 'nodename' returned by \fBuname\fP(2))
103 %e executable filename
104
105 .fi
106 A single % at the end of the template is dropped from the
107 core filename, as is the combination of a % followed by any
108 character other than those listed above.
109 All other characters in the template become a literal
110 part of the core filename.
111 The template may include '/' characters, which are interpreted
112 as delimiters for directory names.
113 The maximum size of the resulting core filename is 64 bytes.
114 The default value in this file is "core".
115 For backward compatibility, if
116 .I /proc/sys/kernel/core_pattern
117 does not include "%p" and
118 .I /proc/sys/kernel/core_uses_pid
119 (see below)
120 is non-zero, then .PID will be appended to the core filename.
121
122 Since version 2.4, Linux has also provided
123 a more primitive method of controlling
124 the name of the core dump file.
125 If the
126 .I /proc/sys/kernel/core_uses_pid
127 file contains the value 0, then a core dump file is simply named
128 .IR core .
129 If this file contains a non-zero value, then the core dump file includes
130 the process ID in a name of the form
131 .IR core.PID .
132 .SH NOTES
133 The
134 .BR gdb (1)
135 .I gcore
136 command can be used to obtain a core dump of a running process.
137
138 If a multithreaded process (or, more precisely, a process that
139 shares its memory with another process by being created with the
140 .B CLONE_VM
141 flag of
142 .BR clone (2))
143 dumps core, then the process ID is always appended to the core filename,
144 unless the process ID was already included elsewhere in the
145 filename via a %p specification in
146 .IR /proc/sys/kernel/core_pattern .
147 (This is primarily useful when employing the LinuxThreads implementation,
148 where each thread of a process has a different PID.)
149 .\" Always including the PID in the name of the core file made
150 .\" sense for LinuxThreads, where each thread had a unique PID,
151 .\" but doesn't seem to serve any purpose with NPTL, where all the
152 .\" threads in a process share the same PID (as POSIX.1 requires).
153 .\" Probably the behavior is maintained so that applications using
154 .\" LinuxThreads continue appending the PID (the kernel has no easy
155 .\" way of telling which threading implementation the userspace
156 .\" application is using). -- mtk, April 2006
157 .SH SEE ALSO
158 .BR gdb (1),
159 .BR getrlimit (2),
160 .BR prctl (2),
161 .BR sigaction (2),
162 .BR elf (5),
163 .BR proc (5),
164 .BR pthreads (7),
165 .BR signal (7)