From 9cd968e2d210bf7a9fb1c64d027d98e7342793b9 Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Thu, 29 Sep 2016 20:12:38 +0800 Subject: [PATCH] move hyper_watch_exec_pty() after get the process pid Signed-off-by: Lai Jiangshan --- src/exec.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/exec.c b/src/exec.c index 3dae8a6..d3ad0b5 100644 --- a/src/exec.c +++ b/src/exec.c @@ -603,13 +603,6 @@ int hyper_run_process(struct hyper_exec *exec) goto out; } - if (hyper_watch_exec_pty(exec) < 0) { - fprintf(stderr, "add pts master event failed\n"); - goto close_tty; - } - - exec->ref++; - if (pipe2(pipe, O_CLOEXEC) < 0) { perror("create pipe between pod init execcmd failed"); goto close_tty; @@ -629,8 +622,14 @@ int hyper_run_process(struct hyper_exec *exec) goto close_tty; } + if (hyper_watch_exec_pty(exec) < 0) { + fprintf(stderr, "add pts master event failed\n"); + goto close_tty; + } + exec->pid = type; list_add_tail(&exec->list, &exec->pod->exec_head); + exec->ref++; fprintf(stdout, "%s process pid %d\n", __func__, exec->pid); ret = 0; out: