aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/interrupt_signals.h
blob: 9500ff89d0c78cf777e25bcae251fd0501a0f26b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include "platform.h"

#include <csignal>

#ifdef _win_
    #ifndef SIGHUP
        #define SIGHUP 1 /* Hangup (POSIX).  */ 
    #endif
#endif

/**
 * Set handler for interrupt signals.
 *
 * All OSes:      SIGINT, SIGTERM (defined by C++ standard)
 * UNIX variants: Also SIGHUP
 * Windows:       CTRL_C_EVENT handled as SIGINT, CTRL_BREAK_EVENT as SIGTERM, CTRL_CLOSE_EVENT as SIGHUP
 *
 * \param handler                       Signal handler to use. Pass nullptr to clear currently set handler.
 */
void SetInterruptSignalsHandler(void (*handler)(int signum));