2

For purposes of my own, I would like to take a regular core dump of my running application - from within the applciation - but continue running the program.

How can I do so? The app has a single process, with multiple threads.

Google core dump looked promising, but is no longer supported. Is there another way?

Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
  • 1
    Possible duplicate of [What is a good way to dump a Linux core file from inside a process?](http://stackoverflow.com/questions/318647/what-is-a-good-way-to-dump-a-linux-core-file-from-inside-a-process) – Mark Plotnick Sep 05 '16 at 08:39

2 Answers2

1

Call fork and then dump core in the forked process. This has one significant disadvantage -- you can't see the stacks of threads other than the one that called fork.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
  • 1
    I was about to write that. Regarding the threads: Depending on the actual application there could be "safe points" (where the threads can be made to "meet") which could be made to let all threads do your suggested procedure. – Daniel Jour Sep 05 '16 at 07:53
0

You can use GDB

Let say I am running an app call matrix (a simple ncurses sample app that emulates the words flow). 

I can obtain the process id by using pgrep and pass to gcore like this:

    gcore `pgrep matrix`
The core file you obtain will be core.pid format like this:
     core.6129

http://linux.byexamples.com/archives/371/gcore-obtain-core-dump-of-current-running-application/

sr3z
  • 400
  • 1
  • 2
  • 10