[CRIU] [PATCH 2/3] restore: call close_old_fds() before forking children

Andrey Vagin avagin at openvz.org
Sat Nov 14 22:07:04 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

If processes share a file descriptor table, they all have their own set
of service descriptors. close_old_fds() closes all file descriptors
execpt service descriptors

Fixes: 9d60724eca71 ("restore: restore mntns before creating private vma-s (v3)")
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 cr-restore.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index c53cb13..90042a8 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1504,6 +1504,12 @@ static int restore_task_with_children(void *_arg)
 		}
 	}
 
+	if (!(ca->clone_flags & CLONE_FILES)) {
+		ret = close_old_fds(current);
+		if (ret)
+			goto err_fini_mnt;
+	}
+
 	/* Restore root task */
 	if (current->parent == NULL) {
 		if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
@@ -1553,11 +1559,6 @@ static int restore_task_with_children(void *_arg)
 	if (create_children_and_session())
 		goto err_fini_mnt;
 
-	if (!(ca->clone_flags & CLONE_FILES)) {
-		ret = close_old_fds(current);
-		if (ret)
-			goto err_fini_mnt;
-	}
 
 	if (unmap_guard_pages())
 		goto err_fini_mnt;
-- 
2.4.3



More information about the CRIU mailing list