Controlling core files (Linux)
Controlling core files (Linux)
core fileファイル再配置:echo/tmp/core.%e.%p >/proc/sys/kernel/core_pattern
Core files get created when a program misbehaves due to a bug, or a violation of the cpu or memory protection mechanisms. The operating system kills the program and creates the core file.
If you don't want core files at all, set "ulimit -c 0"in your startup files. That's the default on many systems; in/etc/profile you may find
If you DO want core files, you need to reset that in your own .bash_profile:
would allow core files but limit them to 50,000 bytes.
You have more control of core files in/proc/sys/kernel/
For example, you can do eliminate the tagged on pid by
Core files will then just be named "core". People do things like that so that a user can choose to put a non-writable file named "core"in directories where they don't want to generate core dumps. That could be a directory (mkdir core) or a file (touch core;chmod 000 core). I've seen it suggested that a symlink named core would redirect the dump to wherever it pointed, but I found that didn't work.
But perhaps more interesting is that you can do:
All corefiles then get tossed to/tmp/corefiles (don't change core_uses_pid if you do this).
Test this with a simple script:
core fileファイル再配置:echo/tmp/core.%e.%p >/proc/sys/kernel/core_pattern
Core files get created when a program misbehaves due to a bug, or a violation of the cpu or memory protection mechanisms. The operating system kills the program and creates the core file.
If you don't want core files at all, set "ulimit -c 0"in your startup files. That's the default on many systems; in/etc/profile you may find
ulimit -S -c 0 > /dev/null 2>&1
If you DO want core files, you need to reset that in your own .bash_profile:
ulimit -c 50000
would allow core files but limit them to 50,000 bytes.
You have more control of core files in/proc/sys/kernel/
For example, you can do eliminate the tagged on pid by
echo "0" > /proc/sys/kernel/core_uses_pid
Core files will then just be named "core". People do things like that so that a user can choose to put a non-writable file named "core"in directories where they don't want to generate core dumps. That could be a directory (mkdir core) or a file (touch core;chmod 000 core). I've seen it suggested that a symlink named core would redirect the dump to wherever it pointed, but I found that didn't work.
But perhaps more interesting is that you can do:
mkdir /tmp/corefiles
chmod 777 /tmp/corefiles
echo "/tmp/corefiles/core" > /proc/sys/kernel/core_pattern
All corefiles then get tossed to/tmp/corefiles (don't change core_uses_pid if you do this).
Test this with a simple script:
# script that dumps core
kill -s SIGSEGV $$