mirror of
https://github.com/clearlinux/hyperstart.git
synced 2026-09-03 12:11:34 +00:00
split hyper_exec_cmd()
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
+17
-9
@@ -631,28 +631,38 @@ static void hyper_free_exec(struct hyper_exec *exec)
|
||||
int hyper_exec_cmd(char *json, int length)
|
||||
{
|
||||
struct hyper_exec *exec;
|
||||
struct hyper_pod *pod = &global_pod;
|
||||
int pipe[2] = {-1, -1};
|
||||
int pid, ret = -1;
|
||||
uint32_t type;
|
||||
|
||||
fprintf(stdout, "call hyper_exec_cmd, json %s, len %d\n", json, length);
|
||||
|
||||
exec = hyper_parse_execcmd(json, length);
|
||||
if (exec == NULL) {
|
||||
fprintf(stderr, "parse exec cmd failed\n");
|
||||
goto out;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = hyper_run_process(exec);
|
||||
if (ret < 0) {
|
||||
hyper_free_exec(exec);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hyper_run_process(struct hyper_exec *exec)
|
||||
{
|
||||
struct hyper_pod *pod = &global_pod;
|
||||
int pipe[2] = {-1, -1};
|
||||
int pid, ret = -1;
|
||||
uint32_t type;
|
||||
|
||||
if (exec->argv == NULL) {
|
||||
fprintf(stderr, "cmd is %p, seq %" PRIu64 ", container %s\n",
|
||||
exec->argv, exec->seq, exec->id);
|
||||
goto free_exec;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (hyper_setup_exec_tty(exec) < 0) {
|
||||
fprintf(stderr, "setup exec tty failed\n");
|
||||
goto free_exec;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (hyper_watch_exec_pty(exec, pod) < 0) {
|
||||
@@ -699,8 +709,6 @@ close_tty:
|
||||
close(exec->stdinfd);
|
||||
close(exec->stdoutfd);
|
||||
close(exec->stderrfd);
|
||||
free_exec:
|
||||
hyper_free_exec(exec);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ int hyper_release_exec(struct hyper_exec *, struct hyper_pod *);
|
||||
int hyper_container_execcmd(struct hyper_pod *pod);
|
||||
int hyper_setup_exec_tty(struct hyper_exec *e);
|
||||
int hyper_dup_exec_tty(struct hyper_exec *e);
|
||||
int hyper_run_process(struct hyper_exec *e);
|
||||
void hyper_exec_process(struct hyper_exec *e);
|
||||
struct hyper_exec *hyper_find_exec_by_pid(struct list_head *head, int pid);
|
||||
struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq);
|
||||
|
||||
Reference in New Issue
Block a user