2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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.
19 #include <sys/types.h>
23 #define PRT_TRACE_ERR(format, args...) do { \
25 snprintf(buf, 255, format, ##args);\
26 write(2, buf, strlen(buf));\
29 #define PRT_TRACE(format, args...) do { \
31 snprintf(buf, 255, format, ##args);\
32 write(1, buf, strlen(buf));\
35 static struct sigaction sig_child_old_act;
36 static struct sigaction sig_pipe_old_act;
38 static void sig_child_handler(int signo, siginfo_t *info, void *data)
43 pid = waitpid(info->si_pid, &status, 0);
45 PRT_TRACE_ERR("SIGCHLD received\n");
49 PRT_TRACE("sig child actend call - %d\n", info->si_pid);
51 ss_core_action_clear(info->si_pid);
54 static void sig_pipe_handler(int signo, siginfo_t *info, void *data)
61 struct sigaction sig_act;
63 sig_act.sa_handler = NULL;
64 sig_act.sa_sigaction = sig_child_handler;
65 sig_act.sa_flags = SA_SIGINFO;
66 sigemptyset(&sig_act.sa_mask);
67 sigaction(SIGCHLD, &sig_act, &sig_child_old_act);
69 sig_act.sa_handler = NULL;
70 sig_act.sa_sigaction = sig_pipe_handler;
71 sig_act.sa_flags = SA_SIGINFO;
72 sigemptyset(&sig_act.sa_mask);
73 sigaction(SIGPIPE, &sig_act, &sig_pipe_old_act);