5#ifndef RUNTIME_PLATFORM_SIGNAL_BLOCKER_H_
6#define RUNTIME_PLATFORM_SIGNAL_BLOCKER_H_
11#if defined(DART_HOST_OS_WINDOWS)
12#error Do not include this file on Windows.
24 sigemptyset(&signal_mask);
25 sigaddset(&signal_mask, sig);
27 int r = pthread_sigmask(SIG_BLOCK, &signal_mask, &old);
34 sigemptyset(&signal_mask);
35 for (
int i = 0;
i < sigs_count;
i++) {
36 sigaddset(&signal_mask, sigs[
i]);
39 int r = pthread_sigmask(SIG_BLOCK, &signal_mask, &old);
46 int r = pthread_sigmask(SIG_SETMASK, &old,
nullptr);
58#define TEMP_FAILURE_RETRY(expression) \
60 ThreadSignalBlocker tsb(SIGPROF); \
63 __result = (expression); \
64 } while ((__result == -1L) && (errno == EINTR)); \
70#define VOID_TEMP_FAILURE_RETRY(expression) \
71 (static_cast<void>(TEMP_FAILURE_RETRY(expression)))
75#define NO_RETRY_EXPECTED(expression) \
77 intptr_t __result = (expression); \
78 if (__result == -1L && errno == EINTR) { \
79 FATAL("Unexpected EINTR errno"); \
84#define VOID_NO_RETRY_EXPECTED(expression) \
85 (static_cast<void>(NO_RETRY_EXPECTED(expression)))
88#define CHECK_IS_BLOCKING(signal) \
90 sigset_t signal_mask; \
91 int __r = pthread_sigmask(SIG_BLOCK, nullptr, &signal_mask); \
94 sigismember(&signal_mask, signal); \
99#define TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
102 ASSERT(CHECK_IS_BLOCKING(SIGPROF)); \
104 __result = (expression); \
105 } while ((__result == -1L) && (errno == EINTR)); \
109#define VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
110 (static_cast<void>(TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression)))
ThreadSignalBlocker(int sig)
ThreadSignalBlocker(int sigs_count, const int sigs[])