2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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.
25 #include "stc_ipt_test.h"
26 #include "stc_ipt_sys.h"
27 #include "stc_ipt_menu.h"
29 #define MAX_ERR_BUFFER 256
31 int stc_ipt_exe_cmd(const char *cmd)
36 char err_buf[MAX_ERR_BUFFER] = { 0, };
40 return STC_ERROR_INVALID_PARAMETER;
43 args = g_strsplit_set(cmd, " ", -1);
48 ret = execv(args[0], args);
50 strerror_r(errno, err_buf, MAX_ERR_BUFFER);
51 msg("Failed to exe cmd " LOG_RED "[%s]" LOG_END, err_buf);
56 if (waitpid(pid, &status, 0) < 0) {
57 strerror_r(errno, err_buf, MAX_ERR_BUFFER);
58 msg("Can't wait for a pid " LOG_RED "[%d %d %s]" LOG_END,
59 pid, status, err_buf);
61 return STC_ERROR_INVALID_OPERATION;
64 return STC_ERROR_NONE;
67 strerror_r(errno, err_buf, MAX_ERR_BUFFER);
68 msg("Failed to fork " LOG_RED "[%s]" LOG_END, err_buf);
71 return STC_ERROR_OPERATION_FAILED;