4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <sensor_log.h>
21 #include <dbus_util.h>
27 #define NEW_FAIL_LIMIT 3
29 using namespace sensor;
31 static void on_signal(int signum)
33 _W("Received SIGNAL(%d : %s)", signum, strsignal(signum));
37 static void on_new_failed(void)
39 static unsigned fail_count = 0;
40 _E("Failed to allocate memory");
43 if (fail_count >= NEW_FAIL_LIMIT) {
49 int main(int argc, char *argv[])
52 std::signal(SIGINT, on_signal);
53 std::signal(SIGHUP, on_signal);
54 std::signal(SIGTERM, on_signal);
55 std::signal(SIGQUIT, on_signal);
56 std::signal(SIGABRT, on_signal);
57 std::signal(SIGCHLD, SIG_IGN);
58 std::signal(SIGPIPE, SIG_IGN);
60 std::set_new_handler(on_new_failed);