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"
29 const int SIGRTANR = SIGRTMIN + 3;
33 AnrMonitor::AnrMonitor() {
34 struct sigaction action;
35 memset(&action, '\0', sizeof(action));
36 sigemptyset(&action.sa_mask);
37 action.sa_flags = SA_RESTART;
38 action.sa_handler = SignalHandler;
40 if (sigaction(SIGRTANR, &action, &old_action_) != 0)
41 _E("sigaction() is failed. errno(%d)", errno);
44 AnrMonitor::~AnrMonitor() {
45 if (sigaction(SIGRTANR, &old_action_, nullptr) != 0)
46 _W("sigaction() is failed. errno(%d)", errno);
49 void AnrMonitor::SignalHandler(int signo) {
50 static unsigned int count;
51 STDERR("===================================================================");
52 STDERR("=================== Application Not Responding ====================");
54 STDERR("============== Application did not respond %d times ===============",
56 STDERR("===================================================================");
59 } // namespace internal
60 } // namespace tizen_cpp