interrupt_signals.h 574 B

12345678910111213141516171819202122
  1. #pragma once
  2. #include "platform.h"
  3. #include <csignal>
  4. #ifdef _win_
  5. #ifndef SIGHUP
  6. #define SIGHUP 1 /* Hangup (POSIX). */
  7. #endif
  8. #endif
  9. /**
  10. * Set handler for interrupt signals.
  11. *
  12. * All OSes: SIGINT, SIGTERM (defined by C++ standard)
  13. * UNIX variants: Also SIGHUP
  14. * Windows: CTRL_C_EVENT handled as SIGINT, CTRL_BREAK_EVENT as SIGTERM, CTRL_CLOSE_EVENT as SIGHUP
  15. *
  16. * \param handler Signal handler to use. Pass nullptr to clear currently set handler.
  17. */
  18. void SetInterruptSignalsHandler(void (*handler)(int signum));