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

Submitted by Kirill Tkhai on June 28, 2017, 3:54 p.m.

Details

Message ID 149866527369.31392.14494297879397403256.stgit@localhost.localdomain
State Accepted
Series "Skip iteration on open files to find parent's leftovers (optimize child creation)"
Commit e8673e12fa2c5de633532cf16e930c4fc1c0bdcc
Headers show

Commit Message

Kirill Tkhai June 28, 2017, 3:54 p.m.
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@virtuozzo.com>
---
 criu/cr-restore.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

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;