From fe5c6c29e133c38848c0316a4f970eef098aa1df Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Wed, 9 Mar 2016 15:41:41 +0800 Subject: [PATCH] use e->errfd directly to create stderr Signed-off-by: Lai Jiangshan --- src/exec.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/exec.c b/src/exec.c index 8e0b297..43f6cf0 100644 --- a/src/exec.c +++ b/src/exec.c @@ -261,11 +261,6 @@ int hyper_dup_exec_tty(int to, struct hyper_exec *e) fd = e->ptyfd; - if (fd < 0) { - perror("open pty device for execcmd failed"); - goto out; - } - if (e->tty && (ioctl(fd, TIOCSCTTY, NULL) < 0)) { perror("ioctl pty device for execcmd failed"); goto out; @@ -284,16 +279,9 @@ int hyper_dup_exec_tty(int to, struct hyper_exec *e) goto out; } - if (e->errseq > 0) { - if (dup2(e->errfd, STDERR_FILENO) < 0) { - perror("dup err pipe to stderr failed"); - goto out; - } - } else { - if (dup2(fd, STDERR_FILENO) < 0) { - perror("dup tty device to stderr failed"); - goto out; - } + if (dup2(e->errfd, STDERR_FILENO) < 0) { + perror("dup err pipe to stderr failed"); + goto out; } ret = 0;