1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
|
.\" Copyright (c) 2006, 2008 by Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Japanese Version Copyright (c) 2006-2008 Akihiro MOTOKI
.\" Translated 2006-04-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2007-01-05, Akihiro MOTOKI, LDP v2.43
.\" Updated 2007-09-03, Akihiro MOTOKI, LDP v2.64
.\" Updated 2008-08-10, Akihiro MOTOKI, LDP v3.05
.\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
.\"
.TH CORE 5 2008-08-26 "Linux" "Linux Programmer's Manual"
.SH ̾
core \- ץե
.SH
ΥʥΥǥեȤΥϡ
ץλ (terminate)
.I "ץե (core dump file)"
뤳ȤǤ롣ץեϡǥ
λΥץΥꥤƤȤեǤ롣
ΥǥХå (㤨
.BR gdb (1))
ɤ߹ǡ
ץबλΥץξ֤뤳ȤǤ롣
ɤΥʥȤ˥ץפ뤫ΥꥹȤ
.BR signal (7)
˽Ƥ롣
ץϥեȡ
.B RLIMIT_CORE
ꤹ뤳Ȥǡ֥סץʥݤ
ץեΥ˾¤ݤȤǤ롣ܺ٤
.BR getrlimit (2)
ȡ
ץե뤬ʤĤ:
.IP * 3
ץեĤʤ
(ǥեȤǤϡե
.I core
Ȥ̾ǡȡǥ쥯ȥ롣
̿̾§ξܺ٤ϲ)
ե褦Ȥǥ쥯ȥ꤬߲ǽǤʤ硢
⤷Ʊ̾Υե뤬¸ߤΥե뤬߲ǽǤ
̾ΥեǤʤ (㤨Сǥ쥯ȥ䥷ܥå)
եϼԤ롣
.IP *
פ˻ȤȤΤƱ̾ (߲ǽʡ̾) ե뤬
Ǥ¸ߤΥեФϡɥ 2İʾ夢硣
.IP *
ץե褦Ȥե륷ƥबեǤ뤫
inode ƻѤƤ뤫ɤ߹ѤǥޥȤƤ硣
ޤϡΥ桼Υǥ̤Υե륷ƥ
(quota) ãƤ롣
.IP *
ץե褦Ȥǥ쥯ȥ꤬¸ߤʤ硣
.IP *
ץΥ
.B RLIMIT_CORE
(եΥ)
.B RLIMIT_FSIZE
(ե륵) 0 ꤵƤ硣
.BR getrlimit (2)
䥷
.I ulimit
ޥɤΥɥ
.RB ( csh (1)
.IR limit )
ȡ
.IP *
ץ¹ԤХʥեɤ߽ФĤͭˤʤäƤʤ硣
.IP *
ץ¹ԤƤ set-user-ID (set-group-ID) ץνͭԤ
桼 (롼) ץμ UID ( GID) Ȱۤʤ
(â
.BR prctl (2)
.B PR_SET_DUMPABLE
ȡ
.BR proc (5)
.I /proc/sys/fs/suid_dumpable
ե⻲ȤΤ)
.\" FIXME . Perhaps relocate discussion of /proc/sys/fs/suid_dumpable
.\" and PR_SET_DUMPABLE to this page?
.SS ץե̾
.\" motoki XXX ƱƤʣƽƤ롣
ǥեȤǤϡץե̾
.I core
Ȥʤ뤬ץե̾Τ˻Ȥƥץ졼Ȥ
.I /proc/sys/kernel/core_pattern
ե뤳Ȥǡե̾ѹ뤳ȤǤ
.RI ( /proc/sys/kernel/core_pattern
Linux 2.6 2.4.21 ʹߤѤǤ)
ƥץ졼Ȥˤ % ؼ (specifier) 뤳ȤǤ롣
ϥե뤬ݤˡʲ֤ͤ롣
.PP
.RS 4
.PD 0
.TP 4
%%
1 Ĥ % ʸ
.TP
%p
פ줿ץΥץID (PID)
.TP
%u
פ줿ץμ¥桼 ID (real UID)
.TP
%g
פ줿ץμ¥롼 ID (real GID)
.TP
%s
פʥֹ
.TP
%t
( (1970 ǯ 1 1 0:00) ÿɽ)
.TP
%h
ۥ̾ (\fBuname\fP(2) ֤ \fInodename\fP Ʊ)
.TP
%e
¹ԥե̾ (ѥ̾Υץեåϴޤޤʤ)
.TP
%c
å夷ץΥեΥ˴ؤ륽եȥ
(Linux 2.6.24 ʹ)
.PD
.RE
.PP
ƥץ졼Ȥ 1 Ĥ % 硢
% ϥե̾ˤϴޤʤޤ
ʤ % ʸȤ߹碌äƱͤǤ롣
ƥץ졼Ȥˤ¾ʸϡ
ե̾ȤƤΤޤȤ롣
ƥץ졼Ȥˤ \(aq/\(aq ʸ뤳ȤǤ
ǥ쥯ȥ̾ζڤʸȲᤵ롣
̤Ȥ륳ե̾κ祵 128 ХȤǤ
(2.6.19 ΥͥǤ 64 Х)
ΥեΥǥեͤ "core" Ǥ롣
ΤΤȤθߴΤᡢ
.I /proc/sys/kernel/core_pattern
"%p" ޤޤ줺
.I /proc/sys/kernel/core_uses_pid
() 0 Ǥʤϡ.PID ե̾ɲä롣
С 2.4 ʹߤ Linux Ǥ
ץե̾椹븶ŪˡƤ롣
.I /proc/sys/kernel/core_uses_pid
ե 0 Ƥ硢ץեñ
.I core
Ȥ̾ˤʤ롣Υե 0 ʳͤƤ硢
ץե
.I core.PID
Ȥ̾ˤʤꡢե̾˥ץ ID ޤޤ롣
.SS פΥץؤΥѥ
ͥ 2.6.19 ʹߤǤϡLinux
.I /proc/sys/kernel/core_pattern
ե̤ιʸݡȤƤ롣
Υեκǽʸѥ (\fB|\fP) ǤС
ιԤλĤʬϼ¹ԤץȤƲᤵ롣
פϡǥΥե˽ޤΤǤϤʤ
ץɸϤȤϤ롣
ʲդ뤳ȡ
.IP * 3
ץХѥ̾ (⤷ϥ롼ȥǥ쥯ȥ \fI/\fP
Хѥ̾) ǻꤵʤФʤʤ
ޤ'|' ʸľ夫ϤʤФʤʤ
.IP *
ץ¹Ԥ뤿ץϡ
桼롼פȤ
.I root
ȤƼ¹Ԥ롣
.IP *
ޥɥ饤ץͿ뤳ȤǤ (ͥ 2.6.24 ʹ)
ϥۥ磻ȥڡǶڤ
(1ԤκĹ 128 ХȤ¤Ǥ)
.IP *
ޥɥ饤ˤϡ嵭ΥꥹȤˤ % ؼҤޤ뤳ȤǤ롣
㤨Сפץ PID Ϥˤϡ
.I %p
ꤹ롣
.SS ɤΥޥåԥפ˽फ椹
ͥ 2.6.23 ʹߤǤϡLinux ͭΥե
.I /proc/PID/coredump_filter
Ȥäơбץ ID ĥץФƥפԤ
ݤˡɤΥꥻȤץե˽फǤ롣
Υեͤϥޥåԥ
.RB ( mmap (2)
) ΥӥåȥޥǤ롣
ޥΤӥåȤåȤȡΥӥåȤб̤
ޥåԥפ롣åȤƤʤΤϥפʤ
ΥեγƥӥåȤϰʲΰ̣ġ
.PP
.PD 0
.RS 4
.TP
bit 0
̵̾Υץ饤١ȥޥåԥ (anonymous private mappings) פ롣
.TP
bit 1
̵̾ζͭޥåԥ (anonymous shared mappings) פ롣
.TP
bit 2
եȴϢդ줿ץ饤١ȥޥåԥ
(file-backed private mappings) פ롣
.TP
bit 3
եȴϢդ줿ͭޥåԥ
(file-backed shared mappings) פ롣
.\" file-backed shared mappings of course also update the underlying
.\" mapped file.
.RE
.PD
.PP
.I coredump_filter
Υǥեͤ 0x3 Ǥ롣
ͤΤ Linux εưȿǤΤǤꡢ
̵̾ꥻ (anonymous memory segments) פ
Ȥ̣롣
.I coredump_filter
ͤ˴ؤ餺ե졼Хåեʤɤ memory-mapped I/O ˴ؤ
ڡϷ褷ƥפ줺 DSO ڡϾ˥פ롣
.BR fork (2)
ǺҥץϿƥץ
.I coredump_filter
ͤѾ롣
.BR execve (2)
.I coredump_filter
ͤݻ롣
Τ褦ˡץ¹Ԥ˿ƥ
.I coredump_filter
ꤷƤΩĤȤ롣
.in +4n
.nf
.RB "$" " echo 0x7 > /proc/self/coredump_filter"
.RB "$" " ./some_program"
.fi
.in
.PP
Υե뤬Τϡͥ뤬ꥪץ
.B CONFIG_ELF_CORE
ͭˤƺ줿Ǥ롣
.SH
.BR gdb (1)
.I gcore
ޥɤѤȡ¹ΥץΥפǤ롣
ޥåɥץ
(Τˤϡ
.BR clone (2)
.B CLONE_VM
줿̥ץȥͭƤץ)
פ硢
ե̾˥ץ ID ɬղä롣
.I /proc/sys/kernel/core_pattern
%p ˤꥳե̾Τɤ¾ξ˥ץ ID
Ǥ˴ޤޤƤϡץ ID ղäʤ
(εǽޤΩĤΤ LinuxThreads ѤƤǤ롣
LinuxThreads ǤϡץθġΥåɤϰۤʤץ ID
ġ)
.\" Always including the PID in the name of the core file made
.\" sense for LinuxThreads, where each thread had a unique PID,
.\" but doesn't seem to serve any purpose with NPTL, where all the
.\" threads in a process share the same PID (as POSIX.1 requires).
.\" Probably the behavior is maintained so that applications using
.\" LinuxThreads continue appending the PID (the kernel has no easy
.\" way of telling which threading implementation the userspace
.\" application is using). -- mtk, April 2006
.SH
ʲΥץ
.I /proc/sys/kernel/core_pattern
եΥѥʸλƤ롣
ʲΥΥåϤΥץλΤǤ
(ѥ뤷
.I core_pattern_pipe_test
Ȥ̾μ¹ԥեƤ)
.PP
.in +4n
.nf
.RB "$" " cc \-o core_pattern_pipe_test core_pattern_pipe_test.c"
.RB "$" " su"
Password:
.RB "#" " echo \(aq|$PWD/core_pattern_pipe_test %p \
UID=%u GID=%g sig=%s\(aq > \e"
.B " /proc/sys/kernel/core_pattern"
.RB "#" " exit"
.RB "$" " sleep 100"
.BR "^\e" " # type control-backslash"
Quit (core dumped)
.RB "$" " cat core.info"
argc=5
argc[0]=</home/mtk/core_pattern_pipe_test>
argc[1]=<20575>
argc[2]=<UID=1000>
argc[3]=<GID=100>
argc[4]=<sig=3>
Total bytes in core dump: 282624
.fi
.in
.SS ץΥ
\&
.nf
/* core_pattern_pipe_test.c */
#define _GNU_SOURCE
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define BUF_SIZE 1024
int
main(int argc, char *argv[])
{
int tot, j;
ssize_t nread;
char buf[BUF_SIZE];
FILE *fp;
char cwd[PATH_MAX];
/* Change our current working directory to that of the
crashing process */
snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
chdir(cwd);
/* Write output to file "core.info" in that directory */
fp = fopen("core.info", "w+");
if (fp == NULL)
exit(EXIT_FAILURE);
/* Display command\-line arguments given to core_pattern
pipe program */
fprintf(fp, "argc=%d\\n", argc);
for (j = 0; j < argc; j++)
fprintf(fp, "argc[%d]=<%s>\\n", j, argv[j]);
/* Count bytes in standard input (the core dump) */
tot = 0;
while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
tot += nread;
fprintf(fp, "Total bytes in core dump: %d\\n", tot);
exit(EXIT_SUCCESS);
}
.fi
.SH Ϣ
.BR bash (1),
.BR gdb (1),
.BR getrlimit (2),
.BR mmap (2),
.BR prctl (2),
.BR sigaction (2),
.BR elf (5),
.BR proc (5),
.BR pthreads (7),
.BR signal (7)
|