From caf59d0f3f789582e43efb766bc2d8a738ca8e41 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Wed, 28 Aug 2019 10:35:50 +0800 Subject: [PATCH] Add signal message to stderr (#19421) * add signal message to stderr, test=develop * add unittests for ugly SignalHandle, test=develop --- paddle/fluid/platform/init.cc | 3 ++- paddle/fluid/platform/init.h | 4 ++++ paddle/fluid/platform/init_test.cc | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/platform/init.cc b/paddle/fluid/platform/init.cc index feb6b1e7dc..d96d1c0315 100644 --- a/paddle/fluid/platform/init.cc +++ b/paddle/fluid/platform/init.cc @@ -203,9 +203,10 @@ void InitDevices(bool init_p2p, const std::vector 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); diff --git a/paddle/fluid/platform/init.h b/paddle/fluid/platform/init.h index 01d66f57dc..d25e79e78f 100644 --- a/paddle/fluid/platform/init.h +++ b/paddle/fluid/platform/init.h @@ -32,5 +32,9 @@ void InitDevices(bool init_p2p, const std::vector devices); void InitDGC(); +#ifndef _WIN32 +void SignalHandle(const char *data, int size); +#endif + } // namespace framework } // namespace paddle diff --git a/paddle/fluid/platform/init_test.cc b/paddle/fluid/platform/init_test.cc index eef1470a90..3f911843c5 100644 --- a/paddle/fluid/platform/init_test.cc +++ b/paddle/fluid/platform/init_test.cc @@ -38,3 +38,10 @@ TEST(InitDevices, CUDA) { ASSERT_EQ(pool.size(), 1U + static_cast(count)); #endif } + +#ifndef _WIN32 +TEST(SignalHandle, SignalHandle) { + std::string msg = "Signal raises"; + paddle::framework::SignalHandle(msg.c_str(), msg.size()); +} +#endif -- GitLab