【问题标题】:How to core dump a Linux program and continue running?如何核心转储 Linux 程序并继续运行?
【发布时间】:2016-09-05 16:01:51
【问题描述】:

出于我自己的目的,我想对正在运行的应用程序进行常规核心转储 - 从应用程序内部 - 但继续运行该程序。

我该怎么做?该应用程序有一个进程,具有多个线程。

Google 核心转储看起来很有希望,但不再受支持。还有其他方法吗?

【问题讨论】:

标签: linux coredump


【解决方案1】:

调用fork,然后在forked 进程中转储核心。这有一个明显的缺点 - 除了调用 fork 的线程堆栈之外,您看不到线程堆栈。

【讨论】:

  • 我正要写那个。关于线程:根据实际应用程序,可能会有“安全点”(可以使线程“相遇”),可以让所有线程执行您建议的程序。
【解决方案2】:

你可以使用 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/

【讨论】:

  • 我的错,我没有明确表示我想在应用程序中这样做。我已经更新了问题。
猜你喜欢
  • 2018-11-08
  • 2017-01-29
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 2011-01-16
  • 2021-12-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多