OSDN Git Service

128c2325aa8ca3577104efcca30e365e75cb2969
[linuxjm/LDP_man-pages.git] / draft / man5 / core.5
1 .\" Copyright (c) 2006, 2008 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.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Japanese Version Copyright (c) 2006-2008 Akihiro MOTOKI
24 .\" Translated 2006-04-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
25 .\" Updated 2007-01-05, Akihiro MOTOKI, LDP v2.43
26 .\" Updated 2007-09-03, Akihiro MOTOKI, LDP v2.64
27 .\" Updated 2008-08-10, Akihiro MOTOKI, LDP v3.05
28 .\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
29 .\"
30 .TH CORE 5 2010-02-27 "Linux" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH Ì¾Á°
33 .\"O core \- core dump file
34 core \- ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë
35 .\"O .SH DESCRIPTION
36 .SH ÀâÌÀ
37 .\"O The default action of certain signals is to cause a process to terminate 
38 .\"O and produce a
39 .\"O .IR "core dump file" ,
40 .\"O a disk file containing an image of the process's memory at 
41 .\"O the time of termination.
42 .\"O This image can be used in a debugger (e.g.,
43 .\"O .BR gdb (1))
44 .\"O to inspect the state of the program at the time that it terminated.
45 .\"O A list of the signals which cause a process to dump core can be found in
46 .\"O .BR signal (7).
47 ¤¢¤ë¼ï¤Î¥·¥°¥Ê¥ë¤ò¼õ¤±¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥¢¥¯¥·¥ç¥ó¤Ï¡¢
48 ¥×¥í¥»¥¹¤ò½ªÎ»¤· (terminate)¡¢
49 .I "¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë (core dump file)"
50 ¤òÀ¸À®¤¹¤ë¤³¤È¤Ç¤¢¤ë¡£¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ç¥£¥¹¥¯¾å¤ËÀ¸À®¤µ¤ì¤ë
51 ½ªÎ»»þ¤Î¥×¥í¥»¥¹¤Î¥á¥â¥ê¥¤¥á¡¼¥¸¤òÆâÍƤȤ¹¤ë¥Õ¥¡¥¤¥ë¤Ç¤¢¤ë¡£
52 ¤³¤Î¥¤¥á¡¼¥¸¤ò¥Ç¥Ð¥Ã¥¬ (Î㤨¤Ð
53 .BR gdb (1))
54 ¤ËÆɤ߹þ¤ó¤Ç¡¢
55 ¥×¥í¥°¥é¥à¤¬½ªÎ»¤·¤¿»þÅÀ¤Î¥×¥í¥°¥é¥à¤Î¾õÂÖ¤ò¸¡ºº¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
56 ¤É¤Î¥·¥°¥Ê¥ë¤ò¼õ¤±¤¿¤È¤­¤Ë¥×¥í¥»¥¹¤¬¥³¥¢¥À¥ó¥×¤òÀ¸À®¤¹¤ë¤«¤Î¥ê¥¹¥È¤Ï
57 .BR signal (7)
58 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¡£
59
60 .\"O A process can set its soft
61 .\"O .B RLIMIT_CORE
62 .\"O resource limit to place an upper limit on the size of the core dump file 
63 .\"O that will be produced if it receives a "core dump" signal; see
64 .\"O .BR getrlimit (2)
65 .\"O for details.
66 ¥×¥í¥»¥¹¤Ï¥½¥Õ¥È¡¦¥ê¥½¡¼¥¹À©¸Â
67 .B RLIMIT_CORE
68 ¤òÀßÄꤹ¤ë¤³¤È¤Ç¡¢¡Ö¥³¥¢¥À¥ó¥×¡×¥·¥°¥Ê¥ë¤ò¼õ¿®¤·¤¿ºÝ¤ËÀ¸À®¤µ¤ì¤ë
69 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º¤Ë¾å¸Â¤ò²Ý¤¹¤³¤È¤¬¤Ç¤­¤ë¡£¾ÜºÙ¤Ï
70 .BR getrlimit (2)
71 ¤ò»²¾È¡£
72
73 .\"O There are various circumstances in which a core dump file is 
74 .\"O not produced:
75 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤¬À¸À®¤µ¤ì¤Ê¤¤¾õ¶·¤¬¤¤¤¯¤Ä¤«¤¢¤ë:
76 .IP * 3
77 .\"O The process does not have permission to write the core file.
78 .\"O (By default the core file is called 
79 .\"O .IR core ,
80 .\"O and is created in the current working directory. 
81 .\"O See below for details on naming.)
82 .\"O Writing the core file will fail if the directory in which 
83 .\"O it is to be created is nonwritable, 
84 .\"O or if a file with the same name exists and 
85 .\"O is not writable
86 .\"O or is not a regular file 
87 .\"O (e.g., it is a directory or a symbolic link).
88 ¥×¥í¥»¥¹¤¬¥³¥¢¥Õ¥¡¥¤¥ë¤ò½ñ¤­¹þ¤àµö²Ä¤ò»ý¤¿¤Ê¤¤¾ì¹ç
89 (¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¥³¥¢¥Õ¥¡¥¤¥ë¤Ï
90 .I core
91 ¤È¤¤¤¦Ì¾Á°¤Ç¡¢¥«¥ì¥ó¥È¡¦¥ï¡¼¥­¥ó¥°¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ËÀ¸À®¤µ¤ì¤ë¡£
92 ̿̾µ¬Â§¤Î¾ÜºÙ¤Ï²¼µ­¤ò»²¾È)¡£
93 ¥³¥¢¥Õ¥¡¥¤¥ë¤òÀ¸À®¤·¤è¤¦¤È¤·¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬½ñ¤­¹þ¤ß²Äǽ¤Ç¤Ê¤¤¾ì¹ç¡¢
94 ¤â¤·¤¯¤ÏƱ¤¸Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤¬½ñ¤­¹þ¤ß²Äǽ¤Ç¤â
95 Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤Ç¤â¤Ê¤¤¾ì¹ç (Î㤨¤Ð¡¢¥Ç¥£¥ì¥¯¥È¥ê¤ä¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯)¡¢
96 ¥³¥¢¥Õ¥¡¥¤¥ë¤ÎÀ¸À®¤Ï¼ºÇÔ¤¹¤ë¡£
97 .IP *
98 .\"O A (writable, regular) file with the same name as would be used for the 
99 .\"O core dump already exists, but there is more than one hard link to that 
100 .\"O file.
101 ¥³¥¢¥À¥ó¥×¤Ë»È¤ª¤¦¤È¤·¤¿¤Î¤ÈƱ¤¸Ì¾Á°¤Î (½ñ¤­¹þ¤ß²Äǽ¤Ê¡¢Ä̾ï¤Î) ¥Õ¥¡¥¤¥ë¤¬
102 ¤¹¤Ç¤Ë¸ºß¤·¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥Ï¡¼¥É¥ê¥ó¥¯¤¬ 2¸Ä°Ê¾å¤¢¤ë¾ì¹ç¡£
103 .IP *
104 .\"O The file system where the core dump file would be created is full; 
105 .\"O or has run out of inodes; or is mounted read-only; 
106 .\"O or the user has reached their quota for the file system.
107 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤òÀ¸À®¤·¤è¤¦¤È¤·¤¿¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬¥Õ¥ë¤Ç¤¢¤ë¤«¡¢
108 inode ¤¬Á´¤Æ»ÈÍѤµ¤ì¤Æ¤¤¤ë¤«¡¢Æɤ߹þ¤ßÀìÍѤǥޥ¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡£
109 ¤Þ¤¿¤Ï¡¢¤½¤Î¥æ¡¼¥¶¤Î¥Ç¥£¥¹¥¯»ÈÍÑÎ̤¬¤½¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î
110 ¥¯¥ª¡¼¥¿ (quota) ¤Ë㤷¤Æ¤¤¤ë¡£
111 .IP *
112 .\"O The directory in which the core dump file is to be created does 
113 .\"O not exist.
114 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤òÀ¸À®¤·¤è¤¦¤È¤·¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¡£
115 .IP *
116 .\"O The
117 .\"O .B RLIMIT_CORE
118 .\"O (core file size) or
119 .\"O .B RLIMIT_FSIZE
120 .\"O (file size) resource limits for the process are set to zero; see
121 .\"O .BR getrlimit (2)
122 .\"O and the documentation of the shell's
123 .\"O .I ulimit
124 .\"O command
125 .\"O .RI ( limit
126 .\"O in
127 .\"O .BR csh (1)).
128 ¥×¥í¥»¥¹Ëè¤Î¥ê¥½¡¼¥¹À©¸Â
129 .B RLIMIT_CORE
130 (¥³¥¢¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º) ¤«
131 .B RLIMIT_FSIZE
132 (¥Õ¥¡¥¤¥ë¥µ¥¤¥º) ¤¬ 0 ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡£
133 .BR getrlimit (2)
134 ¤ä¥·¥§¥ë¤Î
135 .I ulimit
136 ¥³¥Þ¥ó¥É¤Î¥É¥­¥å¥á¥ó¥È
137 .RB ( csh (1)
138 ¤Î
139 .IR limit )
140 ¤ò»²¾È¡£
141 .IP *
142 .\"O The binary being executed by the process does not have read 
143 .\"O permission enabled.
144 ¥×¥í¥»¥¹¤¬¼Â¹Ô¤·¤¿¥Ð¥¤¥Ê¥ê¥Õ¥¡¥¤¥ë¤ÎÆɤ߽Ф·µö²Ä¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç¡£
145 .IP *
146 .\"O The process is executing a set-user-ID (set-group-ID) program
147 .\"O that is owned by a user (group) other than the real user (group) 
148 .\"O ID of the process.
149 .\"O (However, see the description of the
150 .\"O .BR prctl (2)
151 .\"O .B PR_SET_DUMPABLE
152 .\"O operation, and the description of the
153 .\"O .I /proc/sys/fs/suid_dumpable
154 .\"O .\" FIXME . Perhaps relocate discussion of /proc/sys/fs/suid_dumpable
155 .\"O .\" and PR_SET_DUMPABLE to this page?
156 .\"O file in
157 .\"O .BR proc (5).)
158 ¥×¥í¥»¥¹¤¬¼Â¹Ô¤·¤Æ¤¤¤ë set-user-ID (set-group-ID) ¥×¥í¥°¥é¥à¤Î½êÍ­¼Ô¤Î
159 ¥æ¡¼¥¶ (¥°¥ë¡¼¥×) ¤¬¡¢¥×¥í¥»¥¹¤Î¼Â UID (¼Â GID) ¤È°Û¤Ê¤ë¾ì¹ç
160 (⤷¡¢
161 .BR prctl (2)
162 .B PR_SET_DUMPABLE
163 Áàºî¤ÎÀâÌÀ¤È¡¢
164 .BR proc (5)
165 ¤Î
166 .I /proc/sys/fs/suid_dumpable
167 ¥Õ¥¡¥¤¥ë¤ÎÀâÌÀ¤â»²¾È¤Î¤³¤È)¡£
168 .\" FIXME . Perhaps relocate discussion of /proc/sys/fs/suid_dumpable
169 .\" and PR_SET_DUMPABLE to this page?
170 .\"O .SS Naming of core dump files
171 .SS ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Î̾Á°
172 .\"O By default, a core dump file is named 
173 .\"O .IR core ,
174 .\"O but the 
175 .\"O .I /proc/sys/kernel/core_pattern
176 .\"O file (since Linux 2.6 and 2.4.21)
177 .\"O can be set to define a template that is used to name core dump files.
178 .\"O The template can contain % specifiers which are substituted
179 .\"O by the following values when a core file is created:
180 .\" motoki XXX Æ±¤¸ÆâÍƤ¬½ÅÊ£¤·¤Æ½ñ¤«¤ì¤Æ¤¤¤ë¡£
181 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Î̾Á°¤Ï
182 .I core
183 ¤È¤Ê¤ë¤¬¡¢¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Î̾Á°¤ò·è¤á¤ë¤Î¤Ë»È¤ï¤ì¤ë¥Æ¥ó¥×¥ì¡¼¥È¤ò
184 .I /proc/sys/kernel/core_pattern
185 ¥Õ¥¡¥¤¥ë¤ËÄêµÁ¤¹¤ë¤³¤È¤Ç¡¢¥Õ¥¡¥¤¥ë̾¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë
186 .RI ( /proc/sys/kernel/core_pattern
187 ¤Ï Linux 2.6 ¤ª¤è¤Ó 2.4.21 °Ê¹ß¤ÇÍøÍѤǤ­¤ë)¡£
188 ¥Æ¥ó¥×¥ì¡¼¥È¤Ë¤Ï % »Ø¼¨»Ò (specifier) ¤òÆþ¤ì¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
189 ¤³¤ì¤Ï¥³¥¢¥Õ¥¡¥¤¥ë¤¬À¸À®¤µ¤ì¤ëºÝ¤Ë¡¢°Ê²¼¤ÎÃͤËÃÖ¤­´¹¤¨¤é¤ì¤ë¡£
190 .PP
191 .RS 4
192 .PD 0
193 .TP 4
194 %%
195 .\"O a single % character
196 1 ¤Ä¤Î % Ê¸»ú
197 .TP
198 %p
199 .\"O PID of dumped process
200 ¥À¥ó¥×¤µ¤ì¤¿¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID (PID)
201 .TP
202 %u
203 .\"O (numeric) real UID of dumped process
204 ¥À¥ó¥×¤µ¤ì¤¿¥×¥í¥»¥¹¤Î¼Â¥æ¡¼¥¶ ID (real UID)
205 .TP
206 %g
207 .\"O (numeric) real GID of dumped process
208 ¥À¥ó¥×¤µ¤ì¤¿¥×¥í¥»¥¹¤Î¼Â¥°¥ë¡¼¥× ID (real GID)
209 .TP
210 %s
211 .\"O number of signal causing dump
212 ¥À¥ó¥×¤ò°ú¤­µ¯¤³¤·¤¿¥·¥°¥Ê¥ë¤ÎÈÖ¹æ
213 .TP
214 %t
215 .\"O time of dump, expressed as seconds since the
216 .\"O Epoch, 1970-01-01 00:00:00 +0000 (UTC)
217 ¥À¥ó¥×»þ¹ï¡¢µª¸µ (Epoch; 1970-01-01 00:00:00 +0000 (UTC))
218 ¤«¤é¤ÎÉÿô¡£
219 .TP
220 %h
221 .\"O hostname (same as \fInodename\fP returned by \fBuname\fP(2))
222 ¥Û¥¹¥È̾ (\fBuname\fP(2) ¤ÇÊÖ¤µ¤ì¤ë \fInodename\fP ¤ÈƱ¤¸)
223 .TP
224 %e
225 .\"O executable filename (without path prefix)
226 ¼Â¹Ô¥Õ¥¡¥¤¥ë̾ (¥Ñ¥¹Ì¾¤Î¥×¥ì¥Õ¥£¥Ã¥¯¥¹¤Ï´Þ¤Þ¤ì¤Ê¤¤)
227 .TP
228 %c
229 .\"O core file size soft resource limit of crashing process (since Linux 2.6.24)
230 ¥¯¥é¥Ã¥·¥å¤·¤¿¥×¥í¥»¥¹¤Î¥³¥¢¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º¤Ë´Ø¤¹¤ë¥½¥Õ¥È¥ê¥½¡¼¥¹¾å¸Â
231 (Linux 2.6.24 °Ê¹ß)
232 .PD
233 .RE
234 .PP
235 .\"O A single % at the end of the template is dropped from the 
236 .\"O core filename, as is the combination of a % followed by any 
237 .\"O character other than those listed above.
238 ¥Æ¥ó¥×¥ì¡¼¥È¤ÎËöÈø¤Ë 1 ¸Ä¤À¤± % ¤¬¤¢¤ë¾ì¹ç¡¢
239 ¤½¤Î % ¤Ï¥³¥¢¥Õ¥¡¥¤¥ë̾¤Ë¤Ï´Þ¤á¤é¤ì¤Ê¤¤¡£¤Þ¤¿¡¢¾å¤ÇÎóµó¤µ¤ì¤Æ
240 ¤¤¤Ê¤¤ % ¤Èʸ»ú¤ÎÁȤ߹ç¤ï¤»¤¬¤¢¤Ã¤¿¾ì¹ç¤âƱÍͤǤ¢¤ë¡£
241 .\"O All other characters in the template become a literal
242 .\"O part of the core filename.
243 ¥Æ¥ó¥×¥ì¡¼¥È¤Ë¤ª¤±¤ë¾¤Îʸ»ú¤Ï¡¢
244 ¥³¥¢¥Õ¥¡¥¤¥ë̾¤È¤·¤Æ¤½¤Î¤Þ¤Þ»È¤ï¤ì¤ë¡£
245 .\"O The template may include \(aq/\(aq characters, which are interpreted
246 .\"O as delimiters for directory names.
247 ¥Æ¥ó¥×¥ì¡¼¥È¤Ë¤Ï \(aq/\(aq Ê¸»ú¤òÆþ¤ì¤ë¤³¤È¤¬¤Ç¤­¡¢
248 ¥Ç¥£¥ì¥¯¥È¥ê̾¤Î¶èÀÚ¤êʸ»ú¤È²ò¼á¤µ¤ì¤ë¡£
249 .\"O The maximum size of the resulting core filename is 128 bytes (64 bytes
250 .\"O in kernels before 2.6.19).
251 ·ë²Ì¤È¤·¤ÆÀ¸À®¤µ¤ì¤ë¥³¥¢¥Õ¥¡¥¤¥ë̾¤ÎºÇÂ祵¥¤¥º¤Ï 128 ¥Ð¥¤¥È¤Ç¤¢¤ë
252 (2.6.19 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï 64 ¥Ð¥¤¥È)¡£
253 .\"O The default value in this file is "core".
254 ¤³¤Î¥Õ¥¡¥¤¥ë¤Î¥Ç¥Õ¥©¥ë¥ÈÃͤϠ"core" ¤Ç¤¢¤ë¡£
255 .\"O For backward compatibility, if
256 .\"O .I /proc/sys/kernel/core_pattern
257 .\"O does not include "%p" and
258 .\"O .I /proc/sys/kernel/core_uses_pid
259 .\"O (see below)
260 .\"O is nonzero, then .PID will be appended to the core filename.
261 °ÊÁ°¤Î¤â¤Î¤È¤Î¸ß´¹À­¤Î¤¿¤á¡¢
262 .I /proc/sys/kernel/core_pattern
263 ¤Ë "%p" ¤¬´Þ¤Þ¤ì¤º¡¢
264 ¤«¤Ä
265 .I /proc/sys/kernel/core_uses_pid
266 (²¼µ­»²¾È) ¤¬ 0 ¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢.PID ¤¬¥³¥¢¥Õ¥¡¥¤¥ë̾¤ËÄɲ䵤ì¤ë¡£
267
268 .\"O Since version 2.4, Linux has also provided
269 .\"O a more primitive method of controlling
270 .\"O the name of the core dump file.
271 .\"O If the
272 .\"O .I /proc/sys/kernel/core_uses_pid
273 .\"O file contains the value 0, then a core dump file is simply named
274 .\"O .IR core .
275 .\"O If this file contains a nonzero value, then the core dump file includes
276 .\"O the process ID in a name of the form
277 .\"O .IR core.PID .
278 ¥Ð¡¼¥¸¥ç¥ó 2.4 °Ê¹ß¤Î Linux ¤Ç¤Ï
279 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÀ©¸æ¤¹¤ë¸¶»ÏŪ¤ÊÊýË¡¤âÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
280 .I /proc/sys/kernel/core_uses_pid
281 ¥Õ¥¡¥¤¥ë¤ËÃÍ 0 ¤¬½ñ¤«¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Ïñ½ã¤Ë
282 .I core
283 ¤È¤¤¤¦Ì¾Á°¤Ë¤Ê¤ë¡£¤³¤Î¥Õ¥¡¥¤¥ë¤Ë 0 °Ê³°¤ÎÃͤ¬½ñ¤«¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
284 ¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Ï
285 .I core.PID
286 ¤È¤¤¤¦·Á¼°¤Î̾Á°¤Ë¤Ê¤ê¡¢¥Õ¥¡¥¤¥ë̾¤Ë¥×¥í¥»¥¹ ID ¤¬´Þ¤Þ¤ì¤ë¡£
287 .\"O .SS Piping core dumps to a program
288 .SS ¥³¥¢¥À¥ó¥×¤Î¥×¥í¥°¥é¥à¤Ø¤Î¥Ñ¥¤¥×
289 .\"O Since kernel 2.6.19, Linux supports an alternate syntax for the
290 .\"O .I /proc/sys/kernel/core_pattern
291 .\"O file.
292 .\"O If the first character of this file is a pipe symbol (\fB|\fP),
293 .\"O then the remainder of the line is interpreted as a program to be
294 .\"O executed.
295 .\"O Instead of being written to a disk file, the core dump is given as
296 .\"O standard input to the program.
297 .\"O Note the following points:
298 ¥«¡¼¥Í¥ë 2.6.19 °Ê¹ß¤Ç¤Ï¡¢Linux ¤Ï
299 .I /proc/sys/kernel/core_pattern
300 ¥Õ¥¡¥¤¥ë¤ÎÊ̤ι½Ê¸¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤ë¡£
301 ¤³¤Î¥Õ¥¡¥¤¥ë¤ÎºÇ½é¤Îʸ»ú¤¬¥Ñ¥¤¥×µ­¹æ (\fB|\fP) ¤Ç¤¢¤ì¤Ð¡¢
302 ¤½¤Î¹Ô¤Î»Ä¤ê¤ÎÉôʬ¤Ï¼Â¹Ô¤¹¤ë¥×¥í¥°¥é¥à¤È¤·¤Æ²ò¼á¤µ¤ì¤ë¡£
303 ¥³¥¢¥À¥ó¥×¤Ï¡¢¥Ç¥£¥¹¥¯¾å¤Î¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢
304 ¥×¥í¥°¥é¥à¤Îɸ½àÆþÎϤȤ·¤ÆÅϤµ¤ì¤ë¡£
305 °Ê²¼¤ÎÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
306 .IP * 3
307 .\"O The program must be specified using an absolute pathname (or a
308 .\"O pathname relative to the root directory, \fI/\fP),
309 .\"O and must immediately follow the '|' character.
310 ¥×¥í¥°¥é¥à¤ÏÀäÂХѥ¹Ì¾ (¤â¤·¤¯¤Ï¥ë¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê \fI/\fP ¤«¤é¤Î
311 ÁêÂХѥ¹Ì¾) ¤Ç»ØÄꤵ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
312 ¤Þ¤¿¡¢'|' Ê¸»ú¤Îľ¸å¤«¤é»Ï¤á¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
313 .IP *
314 .\"O The process created to run the program runs as user and group
315 .\"O .IR root .
316 ¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ë¤¿¤á¤ËÀ¸À®¤µ¤ì¤ë¥×¥í¥»¥¹¤Ï¡¢
317 ¥æ¡¼¥¶¡¢¥°¥ë¡¼¥×¤È¤â
318 .I root 
319 ¤È¤·¤Æ¼Â¹Ô¤µ¤ì¤ë¡£
320 .IP *
321 .\"O Command-line arguments can be supplied to the
322 .\"O program (since kernel 2.6.24),
323 .\"O delimited by white space (up to a total line length of 128 bytes).
324 ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤ò¥×¥í¥°¥é¥à¤ËÍ¿¤¨¤ë¤³¤È¤¬¤Ç¤­ (¥«¡¼¥Í¥ë 2.6.24 °Ê¹ß)¡¢
325 °ú¤­¿ô¤Ï¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤Ç¶èÀÚ¤ë
326 (1¹Ô¤ÎºÇÂçĹ¤Ï 128 ¥Ð¥¤¥È¤¬¾å¸Â¤Ç¤¢¤ë)¡£
327 .IP *
328 .\"O The command-line arguments can include any of
329 .\"O the % specifiers listed above.
330 .\"O For example, to pass the PID of the process that is being dumped, specify
331 .\"O .I %p
332 .\"O in an argument.
333 ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤Ë¤Ï¡¢¾åµ­¤Î¥ê¥¹¥È¤Ë¤¢¤ë % »Ø¼¨»Ò¤ò´Þ¤á¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
334 Î㤨¤Ð¡¢¥À¥ó¥×¤µ¤ì¤ë¥×¥í¥»¥¹¤Î PID ¤òÅϤ¹¤Ë¤Ï¡¢
335 °ú¤­¿ô¤Ë
336 .I %p
337 ¤ò»ØÄꤹ¤ë¡£
338 .\"O .SS Controlling which mappings are written to the core dump
339 .SS ¤É¤Î¥Þ¥Ã¥Ô¥ó¥°¤ò¥³¥¢¥À¥ó¥×¤Ë½ñ¤­¹þ¤à¤«¤òÀ©¸æ¤¹¤ë
340 .\"O Since kernel 2.6.23, the Linux-specific
341 .\"O .IR /proc/PID/coredump_filter
342 .\"O file can be used to control which memory segments are written to the
343 .\"O core dump file in the event that a core dump is performed for the
344 .\"O process with the corresponding process ID.
345 ¥«¡¼¥Í¥ë 2.6.23 °Ê¹ß¤Ç¤Ï¡¢Linux ¸ÇÍ­¤Î¥Õ¥¡¥¤¥ë
346 .I /proc/PID/coredump_filter
347 ¤ò»È¤Ã¤Æ¡¢Âбþ¤¹¤ë¥×¥í¥»¥¹ ID ¤ò»ý¤Ä¥×¥í¥»¥¹¤ËÂФ·¤Æ¥³¥¢¥À¥ó¥×¤¬¹Ô¤ï¤ì¤ë
348 ºÝ¤Ë¡¢¤É¤Î¥á¥â¥ê¥»¥°¥á¥ó¥È¤ò¥³¥¢¥À¥ó¥×¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤à¤«¤òÀ©¸æ¤Ç¤­¤ë¡£
349
350 .\"O The value in the file is a bit mask of memory mapping types (see
351 .\"O .BR mmap (2)).
352 .\"O If a bit is set in the mask, then memory mappings of the
353 .\"O corresponding type are dumped; otherwise they are not dumped.
354 .\"O The bits in this file have the following meanings:
355 ¤³¤Î¥Õ¥¡¥¤¥ë¤ÎÃͤϥá¥â¥ê¥Þ¥Ã¥Ô¥ó¥°¼ïÊÌ
356 .RB ( mmap (2)
357 »²¾È) ¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¤¢¤ë¡£
358 ¥Þ¥¹¥¯Æâ¤Î¤¢¤ë¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤ë¤È¡¢¤½¤Î¥Ó¥Ã¥È¤ËÂбþ¤¹¤ë¼ïÊ̤Î
359 ¥á¥â¥ê¥Þ¥Ã¥Ô¥ó¥°¤¬¥À¥ó¥×¤µ¤ì¤ë¡£¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤â¤Î¤Ï¥À¥ó¥×¤µ¤ì¤Ê¤¤¡£
360 ¤³¤Î¥Õ¥¡¥¤¥ë¤Î³Æ¥Ó¥Ã¥È¤Ï°Ê²¼¤Î°ÕÌ£¤ò»ý¤Ä¡£
361 .PP
362 .PD 0
363 .RS 4
364 .TP
365 bit 0
366 .\"O Dump anonymous private mappings.
367 ̵̾¤Î¥×¥é¥¤¥Ù¡¼¥È¥Þ¥Ã¥Ô¥ó¥° (anonymous private mappings) ¤ò¥À¥ó¥×¤¹¤ë¡£
368 .TP
369 bit 1
370 .\"O Dump anonymous shared mappings.
371 ̵̾¤Î¶¦Í­¥Þ¥Ã¥Ô¥ó¥° (anonymous shared mappings) ¤ò¥À¥ó¥×¤¹¤ë¡£
372 .TP
373 bit 2
374 .\"O Dump file-backed private mappings.
375 ¥Õ¥¡¥¤¥ë¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¥×¥é¥¤¥Ù¡¼¥È¥Þ¥Ã¥Ô¥ó¥°
376 (file-backed private mappings) ¤ò¥À¥ó¥×¤¹¤ë¡£
377 .TP
378 bit 3
379 .\"O Dump file-backed shared mappings.
380 ¥Õ¥¡¥¤¥ë¤È´ØÏ¢ÉÕ¤±¤é¤ì¤¿¶¦Í­¥Þ¥Ã¥Ô¥ó¥°
381 (file-backed shared mappings) ¤ò¥À¥ó¥×¤¹¤ë¡£
382 .\" file-backed shared mappings of course also update the underlying
383 .\" mapped file.
384 .TP
385 .\"O bit 4 (since Linux 2.6.24)
386 .\"O Dump ELF headers.
387 bit 4 (Linux 2.6.24 °Ê¹ß)
388 ELF ¥Ø¥Ã¥À¤ò¥À¥ó¥×¤¹¤ë¡£
389 .TP
390 .\"O bit 5 (since Linux 2.6.28)
391 .\"O Dump private huge pages.
392 bit 5 (Linux 2.6.28 °Ê¹ß)
393 ¥×¥é¥¤¥Ù¡¼¥È¤Ê¥Ò¥å¡¼¥¸¥Ú¡¼¥¸ (private huge page) ¤ò¥À¥ó¥×¤¹¤ë¡£
394 .TP
395 .\"O bit 6 (since Linux 2.6.28)
396 .\"O Dump shared huge pages.
397 bit 6 (Linux 2.6.28 °Ê¹ß)
398 ¶¦Í­¤µ¤ì¤¿¥Ò¥å¡¼¥¸¥Ú¡¼¥¸ (shared huge page) ¤ò¥À¥ó¥×¤¹¤ë¡£
399 .RE
400 .PD
401 .PP
402 .\"O By default, the following bits are set: 0, 1, 4 (if the
403 .\"O .B CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
404 .\"O kernel configuration option is enabled), and 5.
405 .\"O The value of this file is displayed in hexadecimal.
406 .\"O (The default value is thus displayed as 33.)
407 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¥Ó¥Ã¥È 0, 1, 4, 5 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¡£
408 (¥Ó¥Ã¥È 4 ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤Î¤Ï¡¢¥«¡¼¥Í¥ë¤¬ÀßÄꥪ¥×¥·¥ç¥ó
409 .B CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
410 ¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤Ç¤¢¤ë)¡£
411 ¤³¤Î¥Õ¥¡¥¤¥ë¤ÎÃͤϠ16 ¿Ê·Á¼°¤Çɽ¼¨¤µ¤ì¤ë
412 (¤·¤¿¤¬¤Ã¤Æ¡¢¥Ç¥Õ¥©¥ë¥ÈÃͤϠ33 ¤Èɽ¼¨¤µ¤ì¤ë)¡£
413
414 .\"O Memory-mapped I/O pages such as frame buffer are never dumped, and
415 .\"O virtual DSO pages are always dumped, regardless of the
416 .\"O .I coredump_filter
417 .\"O value.
418 .I coredump_filter
419 ¤ÎÃͤ˴ؤï¤é¤º¡¢¥Õ¥ì¡¼¥à¥Ð¥Ã¥Õ¥¡¤Ê¤É¤Î memory-mapped I/O ¤Ë´Ø¤¹¤ë
420 ¥Ú¡¼¥¸¤Ï·è¤·¤Æ¥À¥ó¥×¤µ¤ì¤º¡¢²¾ÁÛ DSO ¥Ú¡¼¥¸¤Ï¾ï¤Ë¥À¥ó¥×¤µ¤ì¤ë¡£
421
422 .\"O A child process created via
423 .\"O .BR fork (2)
424 .\"O inherits its parent's
425 .\"O .I coredump_filter
426 .\"O value;
427 .\"O the
428 .\"O .I coredump_filter
429 .\"O value is preserved across an
430 .\"O .BR execve (2).
431 .BR fork (2)
432 ¤ÇºîÀ®¤µ¤ì¤ë»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤Î
433 .I coredump_filter
434 ¤ÎÃͤò·Ñ¾µ¤¹¤ë¡£
435 .BR execve (2)
436 ¤ÎÁ°¸å¤Ç
437 .I coredump_filter
438 ¤ÎÃͤÏÊÝ»ý¤µ¤ì¤ë¡£
439
440 .\"O It can be useful to set
441 .\"O .I coredump_filter
442 .\"O in the parent shell before running a program, for example:
443 Îã¤Î¤è¤¦¤Ë¡¢¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¿Æ¥·¥§¥ë¤Î
444 .I coredump_filter
445 ¤òÀßÄꤷ¤Æ¤ª¤¯¤ÈÌòΩ¤Ä¤³¤È¤¬¤¢¤ë¡£
446
447 .in +4n
448 .nf
449 .RB "$" " echo 0x7 > /proc/self/coredump_filter"
450 .RB "$" " ./some_program"
451 .fi
452 .in
453 .PP
454 .\"O This file is only provided if the kernel was built with the
455 .\"O .B CONFIG_ELF_CORE
456 .\"O configuration option.
457 ¤³¤Î¥Õ¥¡¥¤¥ë¤¬Ä󶡤µ¤ì¤ë¤Î¤Ï¡¢¥«¡¼¥Í¥ë¤¬ÀßÄꥪ¥×¥·¥ç¥ó
458 .B CONFIG_ELF_CORE
459 ¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤À¤±¤Ç¤¢¤ë¡£
460 .\"O .SH NOTES
461 .SH È÷¹Í
462 .\"O The 
463 .\"O .BR gdb (1)
464 .\"O .I gcore
465 .\"O command can be used to obtain a core dump of a running process.
466 .BR gdb (1)
467 ¤Î
468 .I gcore
469 ¥³¥Þ¥ó¥É¤ò»ÈÍѤ¹¤ë¤È¡¢¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤Î¥³¥¢¥À¥ó¥×¤ò¼èÆÀ¤Ç¤­¤ë¡£
470
471 .\"O If a multithreaded process (or, more precisely, a process that
472 .\"O shares its memory with another process by being created with the
473 .\"O .B CLONE_VM
474 .\"O flag of
475 .\"O .BR clone (2))
476 .\"O dumps core, then the process ID is always appended to the core filename, 
477 .\"O unless the process ID was already included elsewhere in the
478 .\"O filename via a %p specification in
479 .\"O .IR /proc/sys/kernel/core_pattern .
480 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥»¥¹
481 (¤è¤êÀµ³Î¤Ë¤Ï¡¢
482 .BR clone (2)
483 ¤Î
484 .B CLONE_VM
485 ¤ÇÀ¸À®¤µ¤ì¤¿ÊÌ¥×¥í¥»¥¹¤È¥á¥â¥ê¤ò¶¦Í­¤·¤Æ¤¤¤ë¥×¥í¥»¥¹)
486 ¤¬¥³¥¢¥À¥ó¥×¤òÀ¸À®¤¹¤ë¾ì¹ç¡¢
487 ¥³¥¢¥Õ¥¡¥¤¥ë̾¤Ë¥×¥í¥»¥¹ ID ¤¬É¬¤ºÉղ䵤ì¤ë¡£
488 ¤¿¤À¤·¡¢
489 .I /proc/sys/kernel/core_pattern
490 ¤Î %p »ØÄê¤Ë¤è¤ê¥³¥¢¥Õ¥¡¥¤¥ë̾¤Î¤É¤³¤«Â¾¤Î¾ì½ê¤Ë¥×¥í¥»¥¹ ID ¤¬
491 ¤¹¤Ç¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¥×¥í¥»¥¹ ID ¤¬ËöÈø¤ËÉղ䵤ì¤Ê¤¤¡£
492 .\"O (This is primarily useful when employing the LinuxThreads implementation,
493 .\"O where each thread of a process has a different PID.)
494 (¤³¤Îµ¡Ç½¤¬¤Þ¤ºÌò¤ËΩ¤Ä¤Î¤Ï LinuxThreads ¼ÂÁõ¤òÍøÍѤ·¤Æ¤¤¤ë¾ì¹ç¤Ç¤¢¤ë¡£
495 LinuxThreads ¼ÂÁõ¤Ç¤Ï¡¢¥×¥í¥»¥¹Æâ¤Î¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤Ï°Û¤Ê¤ë¥×¥í¥»¥¹ ID
496 ¤ò»ý¤Ä¡£)
497 .\" Always including the PID in the name of the core file made
498 .\" sense for LinuxThreads, where each thread had a unique PID,
499 .\" but doesn't seem to serve any purpose with NPTL, where all the 
500 .\" threads in a process share the same PID (as POSIX.1 requires).  
501 .\" Probably the behavior is maintained so that applications using 
502 .\" LinuxThreads continue appending the PID (the kernel has no easy 
503 .\" way of telling which threading implementation the userspace 
504 .\" application is using). -- mtk, April 2006
505 .\"O .SH EXAMPLE
506 .SH Îã
507 .\"O The program below can be used to demonstrate the use of the
508 .\"O pipe syntax in the
509 .\"O .I /proc/sys/kernel/core_pattern
510 .\"O file.
511 .\"O The following shell session demonstrates the use of this program
512 .\"O (compiled to create an executable named
513 .\"O .IR core_pattern_pipe_test ):
514 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
515 .I /proc/sys/kernel/core_pattern
516 ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¤¥×¹½Ê¸¤Î»ÈÍÑÎã¤ò¼¨¤·¤Æ¤¤¤ë¡£
517 °Ê²¼¤Î¥·¥§¥ë¤Î¥»¥Ã¥·¥ç¥ó¤Ï¤³¤Î¥×¥í¥°¥é¥à¤Î»ÈÍÑÎã¤ò¼¨¤¹¤â¤Î¤Ç¤¢¤ë
518 (¥³¥ó¥Ñ¥¤¥ë¤·¤Æ
519 .I core_pattern_pipe_test
520 ¤È¤¤¤¦Ì¾Á°¤Î¼Â¹Ô¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Æ¤¤¤ë)¡£
521 .PP
522 .in +4n
523 .nf
524 .RB "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c"
525 .RB "$" " su"
526 Password:
527 .RB "#" " echo \(aq|$PWD/core_pattern_pipe_test %p \
528 UID=%u GID=%g sig=%s\(aq > \e"
529 .B "    /proc/sys/kernel/core_pattern"
530 .RB "#" " exit"
531 .RB "$" " sleep 100"
532 .BR "^\e" "                     # type control-backslash"
533 Quit (core dumped)
534 .RB "$" " cat core.info"
535 argc=5
536 argc[0]=</home/mtk/core_pattern_pipe_test>
537 argc[1]=<20575>
538 argc[2]=<UID=1000>
539 argc[3]=<GID=100>
540 argc[4]=<sig=3>
541 Total bytes in core dump: 282624
542 .fi
543 .in
544 .\"O .SS Program source
545 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
546 \&
547 .nf
548 /* core_pattern_pipe_test.c */
549
550 #define _GNU_SOURCE
551 #include <sys/stat.h>
552 #include <fcntl.h>
553 #include <limits.h>
554 #include <stdio.h>
555 #include <stdlib.h>
556 #include <unistd.h>
557
558 #define BUF_SIZE 1024
559
560 int
561 main(int argc, char *argv[])
562 {
563     int tot, j;
564     ssize_t nread;
565     char buf[BUF_SIZE];
566     FILE *fp;
567     char cwd[PATH_MAX];
568
569     /* Change our current working directory to that of the
570        crashing process */
571
572     snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
573     chdir(cwd);
574
575     /* Write output to file "core.info" in that directory */
576
577     fp = fopen("core.info", "w+");
578     if (fp == NULL)
579         exit(EXIT_FAILURE);
580
581     /* Display command\-line arguments given to core_pattern
582        pipe program */
583
584     fprintf(fp, "argc=%d\\n", argc);
585     for (j = 0; j < argc; j++)
586         fprintf(fp, "argc[%d]=<%s>\\n", j, argv[j]);
587
588     /* Count bytes in standard input (the core dump) */
589
590     tot = 0;
591     while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
592         tot += nread;
593     fprintf(fp, "Total bytes in core dump: %d\\n", tot);
594
595     exit(EXIT_SUCCESS);
596 }
597 .fi
598 .\"O .SH SEE ALSO
599 .SH ´ØÏ¢¹àÌÜ
600 .BR bash (1),
601 .BR gdb (1),
602 .BR getrlimit (2),
603 .BR mmap (2),
604 .BR prctl (2),
605 .BR sigaction (2),
606 .BR elf (5),
607 .BR proc (5),
608 .BR pthreads (7),
609 .BR signal (7)