1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
* Copyright (c)2013-2021 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
/****/
/**
* @file
*
* Custom signal handler
*/
#ifdef ZTS_ENABLE_PYTHON
/**
* In some situations (Python comes to mind) a signal may not make its
* way to libzt, for this reason we make sure to define a custom signal
* handler that can at least process SIGTERMs
*/
#define ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS 1
#endif
#ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
#include "Signals.hpp"
#include "ZeroTierSockets.h"
#include <cstdlib>
#include <signal.h>
void zts_signal_handler(int signal)
{
/*
switch(signal)
{
case SIGINT:
fprintf(stderr, "SIGINT\n");
break;
case SIGABRT:
fprintf(stderr, "SIGABRT\n");
break;
case SIGILL:
fprintf(stderr, "SIGILL\n");
break;
case SIGSEGV:
fprintf(stderr, "SIGSEGV\n");
break;
case SIGFPE:
fprintf(stderr, "SIGFPE\n");
break;
case SIGTERM:
default:
fprintf(stderr, "SIGTERM\n");
break;
}
*/
exit(signal);
}
void zts_install_signal_handlers()
{
signal(SIGINT, &zts_signal_handler);
/*
signal(SIGABRT, &zts_signal_handler);
signal(SIGFPE, &zts_signal_handler);
signal(SIGILL, &zts_signal_handler);
signal(SIGSEGV, &zts_signal_handler);
signal(SIGTERM, &zts_signal_handler);
*/
}
#endif
|