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

Pavel Emelyanov xemul at parallels.com
Fri Jan 11 05:46:10 EST 2013


On 01/11/2013 01:22 PM, Andrey Vagin wrote:
> 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);

Why we _add_ another call to close_old_fds() instead of _moving_ one
from prepare_fds()?

>  	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
> 




More information about the CRIU mailing list