我正在运行自定义2.6.27内核,我只是注意到在段错误期间生成的核心文件大于为进程设置的硬核文件大小限制.
更令人讨厌的是,核心文件有时只会被截断(但不会受到ulimit设置的限制).
例如,这是我将尝试崩溃的程序:
int main(int argc, char **argv)
{
// Get the hard and soft limit from command line
struct rlimit new = {atoi(argv[1]), atoi(argv[1])};
// Create some memory so as to beef up the core file size
void *p = malloc(10 * 1024 * 1024);
if (!p)
return 1;
if (setrlimit(RLIMIT_CORE, &new)) // Set the hard and soft limit
return 2; // for core files produced by this
// process
while (1);
free(p);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是执行: …
什么是稀疏文件,为什么需要它?我唯一能得到的是它是一个非常大的文件,它是高效的(千兆字节).效率如何?