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>
23 #include <sensor_loader.h>
26 #define CAL_NODE_PATH "/sys/class/sensors/ssp_sensor/set_cal_data"
29 static void sig_term_handler(int signo, siginfo_t *info, void *data)
31 char proc_name[NAME_MAX];
33 get_proc_name(info->si_pid, proc_name);
35 _E("Received SIGTERM(%d) from %s(%d)\n", signo, proc_name, info->si_pid);
37 server::get_instance().stop();
40 static void signal_init(void)
42 struct sigaction sig_act;
43 memset(&sig_act, 0, sizeof(struct sigaction));
45 sig_act.sa_handler = SIG_IGN;
46 sigaction(SIGCHLD, &sig_act, NULL);
47 sigaction(SIGPIPE, &sig_act, NULL);
49 sig_act.sa_handler = NULL;
50 sig_act.sa_sigaction = sig_term_handler;
51 sig_act.sa_flags = SA_SIGINFO;
52 sigaction(SIGTERM, &sig_act, NULL);
53 sigaction(SIGABRT, &sig_act, NULL);
54 sigaction(SIGINT, &sig_act, NULL);
57 static void set_cal_data(void)
59 FILE *fp = fopen(CAL_NODE_PATH, "w");
62 _I("Not support calibration_node");
66 fprintf(fp, "%d", SET_CAL);
71 _I("Succeeded to set calibration data");
76 int main(int argc, char *argv[])
78 _I("Sensord started");
84 /* TODO: loader has to be moved to server */
85 sensor_loader::get_instance().load();
87 server::get_instance().run();
88 server::get_instance().stop();
90 _I("Sensord terminated");