OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 #ifndef BIN_SIGNAL_BLOCKER_H_ | |
6 #define BIN_SIGNAL_BLOCKER_H_ | |
7 | |
8 #include "platform/globals.h" | |
9 | |
10 #if defined(TARGET_OS_WINDOWS) | |
11 #error Do not include this file on Windows. | |
12 #endif | |
13 | |
14 #include <signal.h> // NOLINT | |
15 | |
16 namespace dart { | |
17 namespace bin { | |
18 | |
19 class ThreadSignalBlocker { | |
20 public: | |
21 explicit ThreadSignalBlocker(int sig) { | |
22 sigset_t signal_mask; | |
23 sigemptyset(&signal_mask); | |
24 sigaddset(&signal_mask, sig); | |
25 // Add sig to signal mask. | |
26 pthread_sigmask(SIG_BLOCK, &signal_mask, &old); | |
siva
2013/12/13 21:29:14
int result = pthread_sigmask(....);
ASSERT(!retval
Cutch
2013/12/13 22:40:18
Done.
| |
27 } | |
28 | |
29 ~ThreadSignalBlocker() { | |
30 // Restore signal mask. | |
31 pthread_sigmask(SIG_SETMASK, &old, NULL); | |
siva
2013/12/13 21:29:14
Ditto here.
Cutch
2013/12/13 22:40:18
Done.
| |
32 } | |
33 | |
34 private: | |
35 sigset_t old; | |
36 }; | |
37 | |
38 } // namespace bin | |
39 } // namespace dart | |
40 | |
41 #endif // BIN_SIGNAL_BLOCKER_H_ | |
OLD | NEW |