OSDN Git Service

8760879200bdcf1db6f603557020b04075283243
[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-25 "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 .RE
385 .PD
386 .PP
387 .\"O The default value of
388 .\"O .I coredump_filter
389 .\"O is 0x3;
390 .\"O this reflects traditional Linux behavior and means that
391 .\"O only anonymous memory segments are dumped.
392 .I coredump_filter
393 ¤Î¥Ç¥Õ¥©¥ë¥ÈÃͤϠ0x3 ¤Ç¤¢¤ë¡£
394 ¤³¤ÎÃͤÏÀΤ«¤é¤Î Linux ¤ÎµóÆ°¤òÈ¿±Ç¤·¤¿¤â¤Î¤Ç¤¢¤ê¡¢
395 ̵̾¥á¥â¥ê¥»¥°¥á¥ó¥È (anonymous memory segments) ¤À¤±¤¬¥À¥ó¥×¤µ¤ì¤ë
396 ¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
397
398 .\"O Memory-mapped I/O pages such as frame buffer are never dumped, and
399 .\"O virtual DSO pages are always dumped, regardless of the
400 .\"O .I coredump_filter
401 .\"O value.
402 .I coredump_filter
403 ¤ÎÃͤ˴ؤï¤é¤º¡¢¥Õ¥ì¡¼¥à¥Ð¥Ã¥Õ¥¡¤Ê¤É¤Î memory-mapped I/O ¤Ë´Ø¤¹¤ë
404 ¥Ú¡¼¥¸¤Ï·è¤·¤Æ¥À¥ó¥×¤µ¤ì¤º¡¢²¾ÁÛ DSO ¥Ú¡¼¥¸¤Ï¾ï¤Ë¥À¥ó¥×¤µ¤ì¤ë¡£
405
406 .\"O A child process created via
407 .\"O .BR fork (2)
408 .\"O inherits its parents
409 .\"O .I coredump_filter
410 .\"O value;
411 .\"O the
412 .\"O .I coredump_filter
413 .\"O value is preserved across an
414 .\"O .BR execve (2).
415 .BR fork (2)
416 ¤ÇºîÀ®¤µ¤ì¤ë»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤Î
417 .I coredump_filter
418 ¤ÎÃͤò·Ñ¾µ¤¹¤ë¡£
419 .BR execve (2)
420 ¤ÎÁ°¸å¤Ç
421 .I coredump_filter
422 ¤ÎÃͤÏÊÝ»ý¤µ¤ì¤ë¡£
423
424 .\"O It can be useful to set
425 .\"O .I coredump_filter
426 .\"O in the parent shell before running a program, for example:
427 Îã¤Î¤è¤¦¤Ë¡¢¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¿Æ¥·¥§¥ë¤Î
428 .I coredump_filter
429 ¤òÀßÄꤷ¤Æ¤ª¤¯¤ÈÌòΩ¤Ä¤³¤È¤¬¤¢¤ë¡£
430
431 .in +4n
432 .nf
433 .RB "$" " echo 0x7 > /proc/self/coredump_filter"
434 .RB "$" " ./some_program"
435 .fi
436 .in
437 .PP
438 .\"O This file is only provided if the kernel was built with the
439 .\"O .B CONFIG_ELF_CORE
440 .\"O configuration option.
441 ¤³¤Î¥Õ¥¡¥¤¥ë¤¬Ä󶡤µ¤ì¤ë¤Î¤Ï¡¢¥«¡¼¥Í¥ë¤¬ÀßÄꥪ¥×¥·¥ç¥ó
442 .B CONFIG_ELF_CORE
443 ¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¤À¤±¤Ç¤¢¤ë¡£
444 .\"O .SH NOTES
445 .SH È÷¹Í
446 .\"O The 
447 .\"O .BR gdb (1)
448 .\"O .I gcore
449 .\"O command can be used to obtain a core dump of a running process.
450 .BR gdb (1)
451 ¤Î
452 .I gcore
453 ¥³¥Þ¥ó¥É¤ò»ÈÍѤ¹¤ë¤È¡¢¼Â¹ÔÃæ¤Î¥×¥í¥»¥¹¤Î¥³¥¢¥À¥ó¥×¤ò¼èÆÀ¤Ç¤­¤ë¡£
454
455 .\"O If a multithreaded process (or, more precisely, a process that
456 .\"O shares its memory with another process by being created with the
457 .\"O .B CLONE_VM
458 .\"O flag of
459 .\"O .BR clone (2))
460 .\"O dumps core, then the process ID is always appended to the core filename, 
461 .\"O unless the process ID was already included elsewhere in the
462 .\"O filename via a %p specification in
463 .\"O .IR /proc/sys/kernel/core_pattern .
464 ¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¥×¥í¥»¥¹
465 (¤è¤êÀµ³Î¤Ë¤Ï¡¢
466 .BR clone (2)
467 ¤Î
468 .B CLONE_VM
469 ¤ÇÀ¸À®¤µ¤ì¤¿ÊÌ¥×¥í¥»¥¹¤È¥á¥â¥ê¤ò¶¦Í­¤·¤Æ¤¤¤ë¥×¥í¥»¥¹)
470 ¤¬¥³¥¢¥À¥ó¥×¤òÀ¸À®¤¹¤ë¾ì¹ç¡¢
471 ¥³¥¢¥Õ¥¡¥¤¥ë̾¤Ë¥×¥í¥»¥¹ ID ¤¬É¬¤ºÉղ䵤ì¤ë¡£
472 ¤¿¤À¤·¡¢
473 .I /proc/sys/kernel/core_pattern
474 ¤Î %p »ØÄê¤Ë¤è¤ê¥³¥¢¥Õ¥¡¥¤¥ë̾¤Î¤É¤³¤«Â¾¤Î¾ì½ê¤Ë¥×¥í¥»¥¹ ID ¤¬
475 ¤¹¤Ç¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢¥×¥í¥»¥¹ ID ¤¬ËöÈø¤ËÉղ䵤ì¤Ê¤¤¡£
476 .\"O (This is primarily useful when employing the LinuxThreads implementation,
477 .\"O where each thread of a process has a different PID.)
478 (¤³¤Îµ¡Ç½¤¬¤Þ¤ºÌò¤ËΩ¤Ä¤Î¤Ï LinuxThreads ¼ÂÁõ¤òÍøÍѤ·¤Æ¤¤¤ë¾ì¹ç¤Ç¤¢¤ë¡£
479 LinuxThreads ¼ÂÁõ¤Ç¤Ï¡¢¥×¥í¥»¥¹Æâ¤Î¸Ä¡¹¤Î¥¹¥ì¥Ã¥É¤Ï°Û¤Ê¤ë¥×¥í¥»¥¹ ID
480 ¤ò»ý¤Ä¡£)
481 .\" Always including the PID in the name of the core file made
482 .\" sense for LinuxThreads, where each thread had a unique PID,
483 .\" but doesn't seem to serve any purpose with NPTL, where all the 
484 .\" threads in a process share the same PID (as POSIX.1 requires).  
485 .\" Probably the behavior is maintained so that applications using 
486 .\" LinuxThreads continue appending the PID (the kernel has no easy 
487 .\" way of telling which threading implementation the userspace 
488 .\" application is using). -- mtk, April 2006
489 .\"O .SH EXAMPLE
490 .SH Îã
491 .\"O The program below can be used to demonstrate the use of the
492 .\"O pipe syntax in the
493 .\"O .I /proc/sys/kernel/core_pattern
494 .\"O file.
495 .\"O The following shell session demonstrates the use of this program
496 .\"O (compiled to create an executable named
497 .\"O .IR core_pattern_pipe_test ):
498 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
499 .I /proc/sys/kernel/core_pattern
500 ¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¤¥×¹½Ê¸¤Î»ÈÍÑÎã¤ò¼¨¤·¤Æ¤¤¤ë¡£
501 °Ê²¼¤Î¥·¥§¥ë¤Î¥»¥Ã¥·¥ç¥ó¤Ï¤³¤Î¥×¥í¥°¥é¥à¤Î»ÈÍÑÎã¤ò¼¨¤¹¤â¤Î¤Ç¤¢¤ë
502 (¥³¥ó¥Ñ¥¤¥ë¤·¤Æ
503 .I core_pattern_pipe_test
504 ¤È¤¤¤¦Ì¾Á°¤Î¼Â¹Ô¥Õ¥¡¥¤¥ë¤òºîÀ®¤·¤Æ¤¤¤ë)¡£
505 .PP
506 .in +4n
507 .nf
508 .RB "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c"
509 .RB "$" " su"
510 Password:
511 .RB "#" " echo \(aq|$PWD/core_pattern_pipe_test %p \
512 UID=%u GID=%g sig=%s\(aq > \e"
513 .B "    /proc/sys/kernel/core_pattern"
514 .RB "#" " exit"
515 .RB "$" " sleep 100"
516 .BR "^\e" "                     # type control-backslash"
517 Quit (core dumped)
518 .RB "$" " cat core.info"
519 argc=5
520 argc[0]=</home/mtk/core_pattern_pipe_test>
521 argc[1]=<20575>
522 argc[2]=<UID=1000>
523 argc[3]=<GID=100>
524 argc[4]=<sig=3>
525 Total bytes in core dump: 282624
526 .fi
527 .in
528 .\"O .SS Program source
529 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
530 \&
531 .nf
532 /* core_pattern_pipe_test.c */
533
534 #define _GNU_SOURCE
535 #include <sys/stat.h>
536 #include <fcntl.h>
537 #include <limits.h>
538 #include <stdio.h>
539 #include <stdlib.h>
540 #include <unistd.h>
541
542 #define BUF_SIZE 1024
543
544 int
545 main(int argc, char *argv[])
546 {
547     int tot, j;
548     ssize_t nread;
549     char buf[BUF_SIZE];
550     FILE *fp;
551     char cwd[PATH_MAX];
552
553     /* Change our current working directory to that of the
554        crashing process */
555
556     snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
557     chdir(cwd);
558
559     /* Write output to file "core.info" in that directory */
560
561     fp = fopen("core.info", "w+");
562     if (fp == NULL)
563         exit(EXIT_FAILURE);
564
565     /* Display command\-line arguments given to core_pattern
566        pipe program */
567
568     fprintf(fp, "argc=%d\\n", argc);
569     for (j = 0; j < argc; j++)
570         fprintf(fp, "argc[%d]=<%s>\\n", j, argv[j]);
571
572     /* Count bytes in standard input (the core dump) */
573
574     tot = 0;
575     while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
576         tot += nread;
577     fprintf(fp, "Total bytes in core dump: %d\\n", tot);
578
579     exit(EXIT_SUCCESS);
580 }
581 .fi
582 .\"O .SH SEE ALSO
583 .SH ´ØÏ¢¹àÌÜ
584 .BR bash (1),
585 .BR gdb (1),
586 .BR getrlimit (2),
587 .BR mmap (2),
588 .BR prctl (2),
589 .BR sigaction (2),
590 .BR elf (5),
591 .BR proc (5),
592 .BR pthreads (7),
593 .BR signal (7)