简体   繁体   English

是否可以转储核心但不退出流程?

[英]Is it possible to dump the core but not exit the process?

I want to be able to generate a core dump but not exit the process afterwards. 我希望能够生成核心转储,但之后不会退出该进程。 I don't need it to continue execution, just not die. 我不需要它继续执行,只是不死。 This is a C++ Ubuntu process. 这是一个C ++ Ubuntu进程。

I believe I'm dumping the core in a pretty standard way: I catch the offending signal via setting the signal handler with signal(), I set the core size limit via setrlimit() and then I prompt the core dump with signal() and raise(): 我相信我正在以一种非常标准的方式倾倒核心:我通过使用signal()设置信号处理程序来捕获有问题的信号,我通过setrlimit()设置核心大小限制然后我用signal()提示核心转储和raise():

signal(SIGSEGV, OnPosixSignal);

...

void OnPosixSignal(int iSignal)
{
    struct rlimit CoreLimit;
    CoreLimit.rlim_cur = RLIM_INFINITY;
    CoreLimit.rlim_max = RLIM_INFINITY;
    setrlimit(RLIMIT_CORE, &CoreLimit);
    signal(iSignal, SIG_DFL);
    raise(iSignal);
}

Is there something I can do to not have the process exit after dumping the core? 在卸载核心后,我有什么办法可以让流程退出吗?

Thanks a bunch in advance! 提前谢谢!

You can also do that using gcore : 你也可以使用gcore做到这gcore

Generate a core dump of a running program with process ID pid. 使用进程ID pid生成正在运行的程序的核心转储。 Produced file is equivalent to a kernel produced core file as if the process crashed (and if "ulimit -c" were used to set up an appropriate core dump limit). 生成的文件相当于内核生成的核心文件,就像进程崩溃一样(如果“ulimit -c”用于设置适当的核心转储限制)。 Unlike after a crash, after gcore the program remains running without any change. 与崩溃后不同,在gcore之后程序仍在运行而没有任何变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM