[CRIU] [PATCH 09/14] files: close_old_fds before forking children

Andrey Vagin avagin at openvz.org
Fri Jan 11 04:22:40 EST 2013


A few processes can share one fd table. Each process has own set of
service file descriptors and a process knows nothing about servic fds
of another processes. So if two process share one fd table,
close_old_fds will close servic descriptors of another process.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-restore.c    | 1 +
 files.c         | 2 +-
 include/files.h | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/cr-restore.c b/cr-restore.c
index fd2fe0d..210347e 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -993,6 +993,7 @@ static int restore_task_with_children(void *_arg)
 	sigset_t blockmask;
 
 	close_safe(&ca->fd);
+	close_old_fds(current);
 
 	current = ca->item;
 
diff --git a/files.c b/files.c
index d59cee6..34eabfb 100644
--- a/files.c
+++ b/files.c
@@ -496,7 +496,7 @@ static int open_fdinfos(int pid, struct list_head *list, int state)
 	return ret;
 }
 
-static int close_old_fds(struct pstree_item *me)
+int close_old_fds(struct pstree_item *me)
 {
 	DIR *dir;
 	struct dirent *de;
diff --git a/include/files.h b/include/files.h
index 0c727aa..b33ae17 100644
--- a/include/files.h
+++ b/include/files.h
@@ -94,6 +94,7 @@ extern int get_filemap_fd(int pid, VmaEntry *vma_entry);
 extern int prepare_fs(int pid);
 extern int set_fd_flags(int fd, int flags);
 
+extern int close_old_fds(struct pstree_item *me);
 #ifndef AT_EMPTY_PATH
 #define AT_EMPTY_PATH 0x1000
 #endif
-- 
1.7.11.7



More information about the CRIU mailing list