From 0d52c7e9e27cd6e49f79a6ccc2bd0ddd346f2b06 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Wed, 28 Jun 2017 18:54:33 +0300 Subject: [PATCH] forking: Always close pid proc before child creation Child does not know about parent's pid proc fd, and it can't close it by fd. Next patch will do close_old_files() optional, and it will base on the fact there is no leftover fds. So, close pid proc directly. Signed-off-by: Kirill Tkhai Signed-off-by: Andrei Vagin --- criu/cr-restore.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 6ef4fae5d..c256031fb 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -1379,9 +1379,7 @@ static int call_clone_fn(void *arg) } close(fd); - if (ca->clone_flags & CLONE_FILES) - close_pid_proc(); - + close_pid_proc(); pid = clone_noasan(restore_task_with_children, ca->clone_flags | CLONE_PARENT | SIGCHLD, ca); return pid > 0 ? 0 : -1; } @@ -1398,8 +1396,7 @@ static int do_fork_with_pid(struct pstree_item *item, struct ns_id *pid_ns, stru pr_err("Can't set next pid\n"); return -1; } - if (ca->clone_flags & CLONE_FILES) - close_pid_proc(); + close_pid_proc(); pid = clone_noasan(restore_task_with_children, ca->clone_flags | SIGCHLD, ca); if (item == root_item) { /* We want to use it before it's set in restore_task_with_children() */ @@ -1430,9 +1427,6 @@ static int do_fork_with_pid(struct pstree_item *item, struct ns_id *pid_ns, stru return -1; } - if (ca->clone_flags & CLONE_FILES) - close_pid_proc(); - if (block_sigmask(&sig_mask, SIGCHLD) < 0) return -1;