![Ubuntu 生成一些核心转储,但没有生成其他核心转储](https://linux22.com/image/945611/Ubuntu%20%E7%94%9F%E6%88%90%E4%B8%80%E4%BA%9B%E6%A0%B8%E5%BF%83%E8%BD%AC%E5%82%A8%EF%BC%8C%E4%BD%86%E6%B2%A1%E6%9C%89%E7%94%9F%E6%88%90%E5%85%B6%E4%BB%96%E6%A0%B8%E5%BF%83%E8%BD%AC%E5%82%A8.png)
我设置ulimit -c 8
并运行了这个小型 C 程序:
#include<stdio.h>
#include<assert.h>
int main()
{
int x = 4;
int y = 7;
assert(x == 5);
printf("\n Hello! \n\n");
}
正如预期的那样,我收到一条消息,表示程序在“assert”行处中止,并且核心已转储。但是,我检查了当前目录以及/var/crash
,但找不到转储文件。但是,/var/crash
确实包含一些其他核心转储。
答案1
在 Ubuntu 中,核心转储由 Apport 处理。要检查(如果重要的话,我的测试计算机是一台服务器):
doug@s19:~/c$ sudo systemctl status apport.service
● apport.service - LSB: automatic crash report generation
Loaded: loaded (/etc/init.d/apport; generated)
Active: active (exited) since Tue 2022-03-22 15:35:56 PDT; 1 day 23h ago
Docs: man:systemd-sysv-generator(8)
Process: 942 ExecStart=/etc/init.d/apport start (code=exited, status=0/SUCCESS)
Mar 22 15:35:56 s19 systemd[1]: Starting LSB: automatic crash report generation...
Mar 22 15:35:56 s19 apport[942]: * Starting automatic crash report generation: apport
Mar 22 15:35:56 s19 systemd[1]: Started LSB: automatic crash report generation.
Mar 22 15:35:56 s19 apport[942]: ...done.
如果我运行你的代码并查看(我使用locate后跟grep过滤器),那么文件位于/var/lib/apport/coredump
:
doug@s19:~/c$ ls -l /var/lib/apport/coredump
total 384
-r-------- 1 doug root 393216 Mar 24 15:16 core._home_doug_c_ask-1399109.1000.29f992b0-5950-4363-9cc6-9e99d17b3bd0.155465.17161959