2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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 #include "app-core-cpp/anr_monitor_private.hh"
22 #include "app-core-cpp/backtrace_private.hh"
23 #include "common/log_private.hh"
25 #define SIGRTANR (SIGRTMIN + 3)
30 AnrMonitor::AnrMonitor() {
31 struct sigaction action;
32 memset(&action, '\0', sizeof(action));
33 sigemptyset(&action.sa_mask);
34 action.sa_flags = SA_RESTART;
35 action.sa_handler = SignalHandler;
37 if (sigaction(SIGRTANR, &action, &old_action_) != 0)
38 _E("sigaction() is failed. errno(%d)", errno);
41 AnrMonitor::~AnrMonitor() {
42 if (sigaction(SIGRTANR, &old_action_, nullptr) != 0)
43 _W("sigaction() is failed. errno(%d)", errno);
46 void AnrMonitor::SignalHandler(int signo) {
47 static unsigned int count;
48 STDERR("===================================================================");
49 STDERR("=================== Application Not Responding ====================");
51 STDERR("============== Application did not respond %d times ===============",
53 STDERR("===================================================================");
56 } // namespace internal
57 } // namespace tizen_cpp