从进程内部转储Linux核心文件的好方法是什么? [英] What is a good way to dump a Linux core file from inside a process?

查看:220
本文介绍了从进程内部转储Linux核心文件的好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一台服务器(用C和C ++编写),它目前捕获一个SEGV并将一些内部信息转储到一个文件中。我希望生成一个核心文件并在我们抓住SEGV时将其写入磁盘,因此我们的支持代表和客户不必大惊小怪,然后等待崩溃再次发生,以便获得核心文件。我们在过去使用过中止函数,但它受到ulimit规则的约束,并没有帮助。



我们有一些遗留代码读取/ proc / pid / map并手动生成一个核心文件,但它已经过时,并且看起来不太可移植(例如,我猜测它不适用于我们的64位版本)。在Linux进程中生成和转储核心文件的最佳方式是什么?

解决方案

Google有一个库,在一个名为 google-coredumper 的正在运行的流程中。这应该忽略ulimit和其他机制。

生成核心文件的调用文档是这里。根据文档,似乎在信号处理程序中生成核心文件是可行的,但不能保证始终有效。


We have a server (written in C and C++) that currently catches a SEGV and dumps some internal info to a file. I would like to generate a core file and write it to disk at the time we catch the SEGV, so our support reps and customers don't have to fuss with ulimit and then wait for the crash to happen again in order to get a core file. We have used the abort function in the past, but it is subject to the ulimit rules and doesn't help.

We have some legacy code that reads /proc/pid/map and manually generates a core file, but it is out of date, and doesn't seem very portable (for example, I'm guessing it would not work in our 64 bit builds). What is the best way to generate and dump a core file in a Linux process?

解决方案

Google has a library for generating coredumps from inside a running process called google-coredumper. This should ignore ulimit and other mechanisms.

The documentation for the call that generates the core file is here. According to the documentation, it seems that it is feasible to generate a core file in a signal handler, though it is not guaranteed to always work.

这篇关于从进程内部转储Linux核心文件的好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆