add:添加自定义sig_handler
This commit is contained in:
parent
eed787c1bf
commit
5ec7814181
@ -4307,12 +4307,17 @@ class SignalHandling
|
||||
{
|
||||
private:
|
||||
static inline std::function<std::string()> crash_path_getter_ = nullptr;
|
||||
static inline std::function<void(int sig)> user_sig_handler_ = nullptr;
|
||||
|
||||
public:
|
||||
static void register_crash_path(std::function<std::string()>&& crash_path_getter)
|
||||
{
|
||||
crash_path_getter_ = std::move(crash_path_getter);
|
||||
}
|
||||
static void register_user_sig_handler(std::function<void(int sig)>&& user_sig_handler)
|
||||
{
|
||||
user_sig_handler_ = std::move(user_sig_handler);
|
||||
}
|
||||
|
||||
public:
|
||||
static std::vector<int> make_default_signals()
|
||||
@ -4432,8 +4437,7 @@ public:
|
||||
|
||||
if (out_path.empty()) {
|
||||
printer.print(st, stderr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
std::ofstream out(out_path);
|
||||
printer.print(st, out);
|
||||
out.close();
|
||||
@ -4457,7 +4461,9 @@ private:
|
||||
sig_handler(int signo, siginfo_t* info, void* _ctx)
|
||||
{
|
||||
handleSignal(signo, info, _ctx);
|
||||
|
||||
if (user_sig_handler_) {
|
||||
user_sig_handler_(signo);
|
||||
}
|
||||
// try to forward the signal.
|
||||
raise(info->si_signo);
|
||||
|
||||
@ -4476,6 +4482,7 @@ class SignalHandling
|
||||
private:
|
||||
static inline std::function<std::string()> crash_path_getter_ = nullptr;
|
||||
static inline std::function<void(EXCEPTION_POINTERS* info)> crash_use_handler_ = nullptr;
|
||||
static inline std::function<void(int sig)> user_sig_handler_ = nullptr;
|
||||
|
||||
public:
|
||||
static void register_crash_path(std::function<std::string()>&& crash_path_getter)
|
||||
@ -4486,6 +4493,10 @@ public:
|
||||
{
|
||||
crash_use_handler_ = std::move(crash_use_handler);
|
||||
}
|
||||
static void register_user_sig_handler(std::function<void(int sig)>&& user_sig_handler)
|
||||
{
|
||||
user_sig_handler_ = std::move(user_sig_handler);
|
||||
}
|
||||
SignalHandling(const std::vector<int>& = std::vector<int>())
|
||||
: reporter_thread_([]() {
|
||||
/* We handle crashes in a utility thread:
|
||||
@ -4605,9 +4616,12 @@ private:
|
||||
abort();
|
||||
}
|
||||
|
||||
static inline void signal_handler(int)
|
||||
static inline void signal_handler(int sig)
|
||||
{
|
||||
crash_handler(signal_skip_recs);
|
||||
if (user_sig_handler_) {
|
||||
user_sig_handler_(sig);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user