1 .\" Copyright (c) 2006, 2008 by Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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
30 .TH CORE 5 2010-11-15 "Linux" "Linux Programmer's Manual"
33 .\"O core \- core dump file
37 .\"O The default action of certain signals is to cause a process to terminate
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.,
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
47 ある種のシグナルを受けた場合のデフォルトのアクションは、
49 .I "コアダンプファイル (core dump file)"
50 を生成することである。コアダンプファイルは、ディスク上に生成される
51 終了時のプロセスのメモリイメージを内容とするファイルである。
55 プログラムが終了した時点のプログラムの状態を検査することができる。
56 どのシグナルを受けたときにプロセスがコアダンプを生成するかのリストは
60 .\"O A process can set its soft
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)
68 を設定することで、「コアダンプ」シグナルを受信した際に生成される
69 コアダンプファイルのサイズに上限を課すことができる。詳細は
73 .\"O There are various circumstances in which a core dump file is
75 コアダンプファイルが生成されない状況がいくつかある:
77 .\"O The process does not have permission to write the core file.
78 .\"O (By default the core file is called
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
86 .\"O or is not a regular file
87 .\"O (e.g., it is a directory or a symbolic link).
88 プロセスがコアファイルを書き込む許可を持たない場合
91 という名前で、カレント・ワーキング・ディレクトリに生成される。
93 コアファイルを生成しようとしたディレクトリが書き込み可能でない場合、
94 もしくは同じ名前のファイルが存在し、そのファイルが書き込み可能でも
95 通常のファイルでもない場合 (例えば、ディレクトリやシンボリックリンク)、
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
101 コアダンプに使おうとしたのと同じ名前の (書き込み可能な、通常の) ファイルが
102 すでに存在し、そのファイルに対するハードリンクが 2個以上ある場合。
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 または、そのユーザのディスク使用量がそのファイルシステムの
112 .\"O The directory in which the core dump file is to be created does
114 コアダンプファイルを生成しようとしたディレクトリが存在しない場合。
118 .\"O (core file size) or
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
132 (ファイルサイズ) が 0 に設定されている場合。
142 .\"O The binary being executed by the process does not have read
143 .\"O permission enabled.
144 プロセスが実行したバイナリファイルの読み出し許可が有効になっていない場合。
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
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?
158 プロセスが実行している set-user-ID (set-group-ID) プログラムの所有者の
159 ユーザ (グループ) が、プロセスの実 UID (実 GID) と異なる場合
166 .I /proc/sys/fs/suid_dumpable
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
172 .\"O By default, a core dump file is named
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 デフォルトでは、コアダンプファイルの名前は
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 これはコアファイルが生成される際に、以下の値に置き換えられる。
195 .\"O a single % character
199 .\"O PID of dumped process
200 ダンプされたプロセスのプロセスID (PID)
203 .\"O (numeric) real UID of dumped process
204 ダンプされたプロセスの実ユーザ ID (real UID)
207 .\"O (numeric) real GID of dumped process
208 ダンプされたプロセスの実グループ ID (real GID)
211 .\"O number of signal causing dump
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))
221 .\"O hostname (same as \fInodename\fP returned by \fBuname\fP(2))
222 ホスト名 (\fBuname\fP(2) で返される \fInodename\fP と同じ)
225 .\"O executable filename (without path prefix)
226 実行ファイル名 (パス名のプレフィックスは含まれない)
229 .\"O core file size soft resource limit of crashing process (since Linux 2.6.24)
230 クラッシュしたプロセスのコアファイルのサイズに関するソフトリソース上限
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.
245 .\"O The template may include \(aq/\(aq characters, which are interpreted
246 .\"O as delimiters for directory names.
247 テンプレートには \(aq/\(aq 文字を入れることができ、
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
260 .\"O is nonzero, then .PID will be appended to the core filename.
262 .I /proc/sys/kernel/core_pattern
265 .I /proc/sys/kernel/core_uses_pid
266 (下記参照) が 0 でない場合は、.PID がコアファイル名に追加される。
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.
272 .\"O .I /proc/sys/kernel/core_uses_pid
273 .\"O file contains the value 0, then a core dump file is simply named
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
278 バージョン 2.4 以降の Linux では
279 コアダンプファイルの名前を制御する原始的な方法も提供されている。
280 .I /proc/sys/kernel/core_uses_pid
281 ファイルに値 0 が書かれている場合、コアダンプファイルは単純に
283 という名前になる。このファイルに 0 以外の値が書かれている場合、
286 という形式の名前になり、ファイル名にプロセス ID が含まれる。
287 .\"O .SS Piping core dumps to a program
289 .\"O Since kernel 2.6.19, Linux supports an alternate syntax for the
290 .\"O .I /proc/sys/kernel/core_pattern
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
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
301 このファイルの最初の文字がパイプ記号 (\fB|\fP) であれば、
302 その行の残りの部分は実行するプログラムとして解釈される。
303 コアダンプは、ディスク上のファイルに書き込まれるのではなく、
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 また、'|' 文字の直後から始めなければならない。
314 .\"O The process created to run the program runs as user and group
316 プログラムを実行するために生成されるプロセスは、
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 以降)、
326 (1行の最大長は 128 バイトが上限である)。
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
333 コマンドライン引き数には、上記のリストにある % 指示子を含めることができる。
334 例えば、ダンプされるプロセスの PID を渡すには、
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 際に、どのメモリセグメントをコアダンプファイルに書き込むかを制御できる。
350 .\"O The value in the file is a bit mask of memory mapping types (see
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:
358 マスク内のあるビットがセットされると、そのビットに対応する種別の
359 メモリマッピングがダンプされる。セットされていないものはダンプされない。
360 このファイルの各ビットは以下の意味を持つ。
366 .\"O Dump anonymous private mappings.
367 無名のプライベートマッピング (anonymous private mappings) をダンプする。
370 .\"O Dump anonymous shared mappings.
371 無名の共有マッピング (anonymous shared mappings) をダンプする。
374 .\"O Dump file-backed private mappings.
375 ファイルと関連付けられたプライベートマッピング
376 (file-backed private mappings) をダンプする。
379 .\"O Dump file-backed shared mappings.
381 (file-backed shared mappings) をダンプする。
382 .\" file-backed shared mappings of course also update the underlying
385 .\"O bit 4 (since Linux 2.6.24)
386 .\"O Dump ELF headers.
387 bit 4 (Linux 2.6.24 以降)
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) をダンプする。
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) をダンプする。
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
411 このファイルの値は 16 進形式で表示される
412 (したがって、デフォルト値は 33 と表示される)。
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
419 の値に関わらず、フレームバッファなどの memory-mapped I/O に関する
420 ページは決してダンプされず、仮想 DSO ページは常にダンプされる。
422 .\"O A child process created via
424 .\"O inherits its parent's
425 .\"O .I coredump_filter
428 .\"O .I coredump_filter
429 .\"O value is preserved across an
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 例のように、プログラムを実行する前に親シェルの
449 .RB "$" " echo 0x7 > /proc/self/coredump_filter"
450 .RB "$" " ./some_program"
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 このファイルが提供されるのは、カーネルが設定オプション
465 .\"O command can be used to obtain a core dump of a running process.
469 コマンドを使用すると、実行中のプロセスのコアダンプを取得できる。
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
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 .
485 で生成された別プロセスとメモリを共有しているプロセス)
487 コアファイル名にプロセス ID が必ず付加される。
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
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
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
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 ):
515 .I /proc/sys/kernel/core_pattern
516 ファイルのパイプ構文の使用例を示している。
517 以下のシェルのセッションはこのプログラムの使用例を示すものである
519 .I core_pattern_pipe_test
520 という名前の実行ファイルを作成している)。
524 .RB "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c"
527 .RB "#" " echo \(dq|$PWD/core_pattern_pipe_test %p \
528 UID=%u GID=%g sig=%s\(dq > \e"
529 .B " /proc/sys/kernel/core_pattern"
532 .BR "^\e" " # type control-backslash"
534 .RB "$" " cat core.info"
536 argc[0]=</home/mtk/core_pattern_pipe_test>
541 Total bytes in core dump: 282624
544 .\"O .SS Program source
548 /* core_pattern_pipe_test.c */
551 #include <sys/stat.h>
558 #define BUF_SIZE 1024
561 main(int argc, char *argv[])
569 /* Change our current working directory to that of the
572 snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
575 /* Write output to file "core.info" in that directory */
577 fp = fopen("core.info", "w+");
581 /* Display command\-line arguments given to core_pattern
584 fprintf(fp, "argc=%d\\n", argc);
585 for (j = 0; j < argc; j++)
586 fprintf(fp, "argc[%d]=<%s>\\n", j, argv[j]);
588 /* Count bytes in standard input (the core dump) */
591 while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
593 fprintf(fp, "Total bytes in core dump: %d\\n", tot);