2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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 "common/mm_resource_manager_utils.h"
18 #include "lib/mm_resource_manager_priv.h"
20 static struct sigaction rm_segv_old_action;
21 static struct sigaction rm_abrt_old_action;
22 static struct sigaction rm_term_old_action;
24 static void __rm_signal_handler(int signo)
26 MM_RM_DEBUG("signal %d is received", signo);
30 sigaction(SIGSEGV, &rm_segv_old_action, NULL);
33 sigaction(SIGABRT, &rm_abrt_old_action, NULL);
36 sigaction(SIGTERM, &rm_term_old_action, NULL);
45 int _mm_resource_manager_set_signal_handlers(void)
47 struct sigaction sa_exec;
49 sa_exec.sa_handler = __rm_signal_handler;
50 sigemptyset(&sa_exec.sa_mask);
51 sa_exec.sa_flags = SA_RESETHAND;
53 return sigaction(SIGSEGV, &sa_exec, &rm_segv_old_action) != -1
54 && sigaction(SIGABRT, &sa_exec, &rm_abrt_old_action) != -1
55 && sigaction(SIGTERM, &sa_exec, &rm_term_old_action) != -1;