Apache Mesos
signals.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 #ifndef __STOUT_OS_WINDOWS_SIGNALS_HPP__
14 #define __STOUT_OS_WINDOWS_SIGNALS_HPP__
15 
16 #include <errno.h>
17 #include <signal.h>
18 #include <string.h>
19 
20 
21 namespace os {
22 
23 namespace signals {
24 
25 // Installs the given signal handler.
26 inline int install(int signal, void(*handler)(int))
27 {
29 }
30 
31 
32 // Resets the signal handler to the default handler of the signal.
33 inline int reset(int signal)
34 {
36 }
37 
38 
39 // Returns true iff the signal is pending.
40 inline bool pending(int signal)
41 {
43 }
44 
45 
46 // Returns true if the signal has been blocked, or false if the
47 // signal was already blocked.
48 inline bool block(int signal)
49 {
51 }
52 
53 
54 // Returns true if the signal has been unblocked, or false if the
55 // signal was not previously blocked.
56 inline bool unblock(int signal)
57 {
59 }
60 
61 namespace internal {
62 
63 // Suppresses a signal on the current thread for the lifetime of
64 // the Suppressor. The signal *must* be synchronous and delivered
65 // per-thread. The suppression occurs only on the thread of
66 // execution of the Suppressor.
67 struct Suppressor
68 {
69  Suppressor(int _signal)
70  : signal(_signal), pending(false), unblock(false)
71  {
73  }
74 
76  {
78  }
79 
80  // Needed for the SUPPRESS() macro.
81  operator bool() { return true; }
82 };
83 
84 } // namespace internal {
85 
86 } // namespace signals {
87 
88 } // namespace os {
89 
90 #endif // __STOUT_OS_WINDOWS_SIGNALS_HPP__
bool pending(int signal)
Definition: signals.hpp:50
int install(int signal, void(*handler)(int))
Definition: signals.hpp:28
~Suppressor()
Definition: signals.hpp:75
Suppressor(int _signal)
Definition: signals.hpp:69
bool block(int signal)
Definition: signals.hpp:61
int reset(int signal)
Definition: signals.hpp:39
bool unblock(int signal)
Definition: signals.hpp:80
#define UNIMPLEMENTED
Definition: unimplemented.hpp:29