2

I'm using boost signal handler in order to properly teardown my process when a signal arrives (SIGTERM, SIGSEGV and SIGABRT).

However, after the teardown the process, I'd like to continue the default system flow of signal handling (that terminates the process and generate crash dump file).

How should I do call this default handler from my callback ?

Thanks !

#include <boost/asio/signal_set.hpp>


void signal_handler() {
  boost::thread([](){
    boost::asio::io_context io_context;
    boost::asio::signal_set signals(io_context, SIGTERM, SIGSEGV, SIGABRT);
    spdlog::debug("Started waiting for signals");
    signals.async_wait([](const boost::system::error_code& error,
                          int signal_number) {
       if (!error) {
         print(std::fmt("got signal {}. teardown the process", signal_number));
         teardown(); 
       } else {
         print("error in getting the signal");
       }
       // HERE I'd like to call the standard signal handler in order to produce crash
       // dump file and kill the process. 
     });
    io_context.run();
  });
}
Zohar81
  • 4,554
  • 5
  • 29
  • 82
  • It doesn't even restore the old signal handlers when you cancel it https://stackoverflow.com/questions/25524151/boostasiosignal-set-does-not-restore-previous-signal-handlers so i imagine it doesn't offer the ability to call them either – Alan Birtles Sep 07 '22 at 06:48
  • To "create a dump file and kill the process", call [`std::abort`](https://en.cppreference.com/w/cpp/utility/program/abort). – Some programmer dude Sep 07 '22 at 06:54
  • @Someprogrammerdude, but since I also catch SIGABRT in the signal handler, I might have a loop here, no? – Zohar81 Sep 07 '22 at 07:59

0 Answers0