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 "include/ss_data.h"
22 #include "ss_predefine.h"
25 enum ss_core_cmd_type {
30 struct _internal_msg {
35 static int core_pipe[2];
37 static int _ss_core_action_run(void *user_data,
38 struct ss_run_queue_entry *rq_entry)
40 struct ss_action_entry *act_entry = rq_entry->action_entry;
44 rq_entry->state = SS_STATE_RUNNING;
45 ret = act_entry->predefine_action(rq_entry->argc, rq_entry->argv);
48 PRT_TRACE_ERR("[SYSMAN] predefine action failed");
51 snprintf(tmp, sizeof(tmp), "/proc/%d/status", ret);
52 if (access(tmp, R_OK) == 0)
53 rq_entry->forked_pid = ret;
60 rq_entry->forked_pid = -1;
61 rq_entry->state = SS_STATE_DONE;
62 ss_core_action_clear(-1);
66 static int core_pipe_cb(void *userdata, Ecore_Fd_Handler * fd_handler)
68 struct ss_main_data *ad = (struct ss_main_data *)userdata;
69 struct _internal_msg p_msg;
71 if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) {
73 ("ecore_main_fd_handler_active_get error , return\n");
77 read(core_pipe[0], &p_msg, sizeof(struct _internal_msg));
81 ss_run_queue_run(SS_STATE_INIT, _ss_core_action_run, ad);
83 case SS_CORE_ACT_CLEAR:
84 ss_run_queue_del_bypid(p_msg.pid);
90 int ss_core_action_run()
92 struct _internal_msg p_msg;
94 p_msg.type = SS_CORE_ACT_RUN;
96 write(core_pipe[1], &p_msg, sizeof(struct _internal_msg));
101 int ss_core_action_clear(int pid)
103 struct _internal_msg p_msg;
105 p_msg.type = SS_CORE_ACT_CLEAR;
107 write(core_pipe[1], &p_msg, sizeof(struct _internal_msg));
112 int ss_core_init(struct ss_main_data *ad)
114 if (pipe(core_pipe) < 0) {
115 PRT_TRACE_ERR("pipe cannot create");
119 ecore_main_fd_handler_add(core_pipe[0], ECORE_FD_READ,
120 core_pipe_cb, ad, NULL, NULL);