[CRIU] [PATCH 5/7] forking: Always close pid proc before child creation

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 28 18:54:33 MSK 2017


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 <ktkhai at virtuozzo.com>
---
 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 2c505f6ea..527606d9f 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1302,9 +1302,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;
 }
@@ -1321,8 +1319,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() */
@@ -1353,9 +1350,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;
 



More information about the CRIU mailing list