未验证 提交 caf59d0f 编写于 作者: Z Zeng Jinle 提交者: GitHub

Add signal message to stderr (#19421)

* add signal message to stderr, test=develop

* add unittests for ugly SignalHandle, test=develop
上级 efb05ba2
......@@ -203,9 +203,10 @@ void InitDevices(bool init_p2p, const std::vector<int> devices) {
}
#ifndef _WIN32
static void SignalHandle(const char *data, int size) {
void SignalHandle(const char *data, int size) {
auto file_path = string::Sprintf("/tmp/paddle.%d.dump_info", ::getpid());
try {
LOG(WARNING) << "Signal raises!\n" + std::string(data, size);
std::ofstream dump_info;
dump_info.open(file_path, std::ios::app);
dump_info << std::string(data, size);
......
......@@ -32,5 +32,9 @@ void InitDevices(bool init_p2p, const std::vector<int> devices);
void InitDGC();
#ifndef _WIN32
void SignalHandle(const char *data, int size);
#endif
} // namespace framework
} // namespace paddle
......@@ -38,3 +38,10 @@ TEST(InitDevices, CUDA) {
ASSERT_EQ(pool.size(), 1U + static_cast<unsigned>(count));
#endif
}
#ifndef _WIN32
TEST(SignalHandle, SignalHandle) {
std::string msg = "Signal raises";
paddle::framework::SignalHandle(msg.c_str(), msg.size());
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册