From 684e85cc5ebf12cbacc5a72dd24c16aa2a1ca4c1 Mon Sep 17 00:00:00 2001 From: Gao feng Date: Thu, 24 Sep 2015 16:58:42 +0800 Subject: [PATCH] recyle resources of process which created by clone Signed-off-by: Gao feng --- src/exec.c | 4 +++- src/init.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/exec.c b/src/exec.c index 6fea52e..e0a04f3 100644 --- a/src/exec.c +++ b/src/exec.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "syscall.h" @@ -407,7 +408,8 @@ int hyper_exec_cmd(char *json, int length) } arg.exec = exec; - pid = clone(hyper_do_exec_cmd, stack + stacksize, CLONE_VM| CLONE_FILES, &arg); + pid = clone(hyper_do_exec_cmd, stack + stacksize, CLONE_VM| CLONE_FILES| SIGCHLD, &arg); + fprintf(stdout, "do_exec_cmd pid %d\n", pid); free(stack); if (pid < 0) { perror("clone hyper_do_exec_cmd failed"); diff --git a/src/init.c b/src/init.c index dfd6a96..7893c08 100644 --- a/src/init.c +++ b/src/init.c @@ -468,7 +468,7 @@ int hyper_start_containers(struct hyper_pod *pod) goto out; } - pid = clone(hyper_do_start_containers, stack + stacksize, CLONE_VM| CLONE_FILES, &arg); + pid = clone(hyper_do_start_containers, stack + stacksize, CLONE_VM| CLONE_FILES| SIGCHLD, &arg); free(stack); if (pid < 0) { perror("enter container pid ns failed"); @@ -932,7 +932,7 @@ static int hyper_cmd_read_file(char *json, int length, uint32_t *datalen, uint8_ arg.data = data; sprintf(arg.root, "/tmp/hyper/%s/root/%s/", c->id, c->rootfs); - pid = clone(hyper_do_cmd_read_file, stack + stacksize, CLONE_VM, &arg); + pid = clone(hyper_do_cmd_read_file, stack + stacksize, CLONE_VM| SIGCHLD, &arg); free(stack); if (pid < 0) { perror("fail to fork writter process");