container: fix the fail to start bug if container has no tty

BU reported by @henrysher.

    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] setup pty device /dev/null for exec
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] ioctl pty device for execcmd failed: Inappropriate ioctl for device
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] setup tty failed
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] hyper send type 10, len 0
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] wait for container started failed
    [HYPER INFO  0531 20:54:^@55 26892 qemu_process.go] [:53] [console] container 2e60d916bb16655746830d89e1503c7067ef13560883a6ba62a77f11c44cadc8 init exit code -1

Signed-off-by: Gao feng <feng@hyper.sh>
This commit is contained in:
Gao feng
2015-06-01 14:52:34 +08:00
parent 980f7fda4c
commit 953cc08de3
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -411,6 +411,8 @@ int hyper_start_container(struct hyper_container *container)
goto fail;
}
container->exec.pid = pid;
/* wait for ready message */
if (hyper_get_type_block(arg.pipe[0], &type) < 0 || type != READY) {
fprintf(stdout, "wait for container started failed\n");
@@ -420,7 +422,6 @@ int hyper_start_container(struct hyper_container *container)
close(arg.pipe[0]);
close(arg.pipe[1]);
container->exec.pid = pid;
fprintf(stdout, "container %s init pid is %d\n", container->id, pid);
return 0;
+1 -1
View File
@@ -132,7 +132,7 @@ int hyper_dup_exec_tty(int to, struct hyper_exec *e)
return -1;
}
if (ioctl(fd, TIOCSCTTY, NULL) < 0) {
if (e->seq && (ioctl(fd, TIOCSCTTY, NULL) < 0)) {
perror("ioctl pty device for execcmd failed");
return -1;
}