UNIX Core Files

在UNIX系统上运行程序异常终止时,操作系统会在当前工作目录创建core文件,该文件包含程序崩溃时的信息,可用于调试。若不用于诊断应用程序的错误,可安全删除。还介绍了防止core文件过大的方法,如创建同名目录或设置文件大小限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Q: Why is there a file called core in my directory and why is it so big? Can I delete it?

When you are running a program on a UNIX machine that terminates abnormally, possibly because it crashed, the operating system creates a core file in the current working directory. The system dumps information into the core file about what the program was doing at the time it crashed, e.g., which subroutine it was calling or what memory address it was accessing. The format of the information in this file is pretty cryptic, but the file can be post-processed by an appropriate debugging tool to give application developers useful information. If you are not trying to diagnose a bug in an application, the file contains no other useful information and can be safely deleted. In fact, it should be deleted because often it is quite large (>100 MB).

How can you prevent the core file from getting so large? One option is to create a directory named core in your current working directory. When the application crashes, the operating system cannot write the core file because a directory with the name already exists. A second option is to set a limit on how big the core file is allowed to grow using the command

limit coredumpize xxxx

xxxx is the maximum size in kB that the core file is allowed to be. In theory, the core file will never exceed the limit. However, in practice, some operating systems ignore it. This command has been incorporated into the standard NML .cshrc file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值