suricata
util-signal.c
Go to the documentation of this file.
1
/* Copyright (C) 2007-2012 Open Information Security Foundation
2
*
3
* You can copy, redistribute or modify this Program under the terms of
4
* the GNU General Public License version 2 as published by the Free
5
* Software Foundation.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* version 2 along with this program; if not, write to the Free Software
14
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
* 02110-1301, USA.
16
*/
17
18
/**
19
* \file
20
*
21
* \author Anoop Saldanha <anoopsaldanha@gmail.com>
22
*/
23
24
#include "
suricata-common.h
"
25
#include "
suricata.h
"
26
#include "
util-debug.h
"
27
#include "
util-signal.h
"
28
29
int
UtilSignalBlock
(
int
signum)
30
{
31
#ifndef OS_WIN32
32
sigset_t x;
33
if
(sigemptyset(&x) < 0)
34
return
-1;
35
if
(sigaddset(&x, signum) < 0)
36
return
-1;
37
/* don't use sigprocmask(), as it's undefined for
38
* multithreaded programs. Use phtread_sigmask().
39
*/
40
if
(pthread_sigmask(SIG_BLOCK, &x, NULL) != 0)
41
return
-1;
42
#endif
43
return
0;
44
}
45
46
int
UtilSignalUnblock
(
int
signum)
47
{
48
#ifndef OS_WIN32
49
sigset_t x;
50
if
(sigemptyset(&x) < 0)
51
return
-1;
52
if
(sigaddset(&x, signum) < 0)
53
return
-1;
54
if
(pthread_sigmask(SIG_UNBLOCK, &x, NULL) != 0)
55
return
-1;
56
#endif
57
return
0;
58
}
59
60
void
UtilSignalHandlerSetup
(
int
sig,
void
(*handler)(
int
))
61
{
62
#ifdef OS_WIN32
63
signal(sig, handler);
64
#else
65
struct
sigaction action;
66
memset(&action, 0x00,
sizeof
(
struct
sigaction));
67
68
action.sa_handler = handler;
69
sigemptyset(&(action.sa_mask));
70
sigaddset(&(action.sa_mask),sig);
71
action.sa_flags = 0;
72
sigaction(sig, &action, 0);
73
#endif
/* OS_WIN32 */
74
}
suricata-common.h
suricata.h
util-debug.h
UtilSignalUnblock
int UtilSignalUnblock(int signum)
Definition
util-signal.c:46
UtilSignalHandlerSetup
void UtilSignalHandlerSetup(int sig, void(*handler)(int))
Definition
util-signal.c:60
UtilSignalBlock
int UtilSignalBlock(int signum)
Definition
util-signal.c:29
util-signal.h
src
util-signal.c
Generated on Wed Jul 23 2025 10:11:01 for suricata by
1.9.8