forked from ravinet/mahimahi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignalfd.hh
39 lines (28 loc) · 838 Bytes
/
signalfd.hh
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
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef SIGNALFD_HH
#define SIGNALFD_HH
#include <sys/signalfd.h>
#include <initializer_list>
#include "file_descriptor.hh"
/* wrapper class for Unix signal masks and signal file descriptor */
class SignalMask
{
private:
sigset_t mask_;
public:
SignalMask( const std::initializer_list< int > signals );
const sigset_t & mask( void ) const { return mask_; }
void set_as_mask( void ) const;
static SignalMask current_mask( void );
bool operator==( const SignalMask & other ) const;
};
class SignalFD
{
private:
FileDescriptor fd_;
public:
SignalFD( const SignalMask & signals );
FileDescriptor & fd( void ) { return fd_; }
signalfd_siginfo read_signal( void ); /* read one signal */
};
#endif /* SIGNALFD_HH */