From 41366ae88ac355d0828105f9b6b44d740e7d7d0e Mon Sep 17 00:00:00 2001 From: Gao feng Date: Mon, 19 Sep 2016 14:52:11 +0800 Subject: [PATCH] setup init_pid of pod until pod started successfully In this case, there is no container init running, we cannot expect hyper_release_exec will be called after terminating all processes. With this patch, the destroy event will not try to kill running container processes, it will call shutdown immediately. Signed-off-by: Gao feng --- src/init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/init.c b/src/init.c index 9264c7e..e8a879a 100644 --- a/src/init.c +++ b/src/init.c @@ -288,7 +288,7 @@ static int hyper_setup_pod_init(struct hyper_pod *pod) uint32_t type; void *stack; - int ret = -1; + int ret = -1, init_pid; if (pipe2(arg.ctl_pipe, O_CLOEXEC) < 0) { perror("create pipe between hyper init and pod init failed"); @@ -303,13 +303,13 @@ static int hyper_setup_pod_init(struct hyper_pod *pod) arg.pod = pod; - pod->init_pid = clone(hyper_pod_init, stack + stacksize, flags, &arg); + init_pid = clone(hyper_pod_init, stack + stacksize, flags, &arg); free(stack); - if (pod->init_pid < 0) { + if (init_pid < 0) { perror("create container init process failed"); goto out; } - fprintf(stdout, "pod init pid %d\n", pod->init_pid); + fprintf(stdout, "pod init pid %d\n", init_pid); /* Wait for container start */ if (hyper_get_type(arg.ctl_pipe[0], &type) < 0) { @@ -322,6 +322,7 @@ static int hyper_setup_pod_init(struct hyper_pod *pod) goto out; } + pod->init_pid = init_pid; ret = 0; out: close(arg.ctl_pipe[1]);