2 * Copyright (C) 2012 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ART_RUNTIME_SIGNAL_SET_H_
18 #define ART_RUNTIME_SIGNAL_SET_H_
22 #include "base/logging.h"
29 if (sigemptyset(&set_) == -1) {
30 PLOG(FATAL) << "sigemptyset failed";
34 void Add(int signal) {
35 if (sigaddset(&set_, signal) == -1) {
36 PLOG(FATAL) << "sigaddset " << signal << " failed";
41 if (pthread_sigmask(SIG_BLOCK, &set_, nullptr) != 0) {
42 PLOG(FATAL) << "pthread_sigmask failed";
47 // Sleep in sigwait() until a signal arrives. gdb causes EINTR failures.
49 int rc = TEMP_FAILURE_RETRY(sigwait(&set_, &signal_number));
51 PLOG(FATAL) << "sigwait failed";
62 #endif // ART_RUNTIME_SIGNAL_SET_H_