Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c

ubuntu

core

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.

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(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!

like image 945
user2062604 Avatar asked Jun 18 '15 14:06

user2062604


1 Answers

You can also do that using gcore:

Generate a core dump of a running program with process 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). Unlike after a crash, after gcore the program remains running without any change.

like image 175
Maxim Egorushkin Avatar answered Oct 26 '22 19:10

Maxim Egorushkin