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.
21 #include <sensor_log.h>
22 #include <dbus_util.h>
28 #define NEW_FAIL_LIMIT 3
30 using namespace sensor;
32 static void on_signal(int signum)
34 _W("Received SIGNAL(%d : %s)", signum, strsignal(signum));
38 static void on_new_failed(void)
40 static unsigned fail_count = 0;
41 _E("Failed to allocate memory");
44 if (fail_count >= NEW_FAIL_LIMIT) {
52 int main(int argc, char *argv[])
55 std::signal(SIGINT, on_signal);
56 std::signal(SIGHUP, on_signal);
57 std::signal(SIGTERM, on_signal);
58 std::signal(SIGQUIT, on_signal);
59 std::signal(SIGABRT, on_signal);
60 std::signal(SIGCHLD, SIG_IGN);
61 std::signal(SIGPIPE, SIG_IGN);
63 std::set_new_handler(on_new_failed);