Files
pytorch/caffe2/utils/signal_handler.h
Pritam Damania dc8a8cea79 Move caffe2 signal_handler to c10. (#56717)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56717

The signal_handler was under the caffe2 namespacee but was being used
by PyTorch as well.

I've fixed this my moving it to the c10 namespace where now both C2 and PyTorch
can use it.

The signal_handler interface in caffe2/utils/signal_handler.h is kept the same
for backward compatiblity for C2, but most of the commmon code is moved to c10.
ghstack-source-id: 127446929

Test Plan: waitforbuildbot

Reviewed By: ezyang

Differential Revision: D27946738

fbshipit-source-id: d6228d1a0108f4c807d405e7a0bb799c5375388f
2021-04-26 23:08:12 -07:00

25 lines
698 B
C++

#pragma once
#include <c10/util/signal_handler.h>
namespace caffe2 {
#if defined(C10_SUPPORTS_FATAL_SIGNAL_HANDLERS)
class TORCH_API C2FatalSignalHandler : public c10::FatalSignalHandler {
public:
void fatalSignalHandlerPostProcess() override;
static C2FatalSignalHandler& getInstance();
private:
explicit C2FatalSignalHandler();
};
// This works by setting up certain fatal signal handlers. Previous fatal
// signal handlers will still be called when the signal is raised. Defaults
// to being off.
TORCH_API void setPrintStackTracesOnFatalSignal(bool print);
TORCH_API bool printStackTracesOnFatalSignal();
#endif // defined(C10_SUPPORTS_FATAL_SIGNAL_HANDLER)
} // namespace caffe2