[CRIU] [PATCH 6/8] sig: Block signals once before forking children

Andrew Vagin avagin at parallels.com
Wed Aug 6 05:58:57 PDT 2014


On Wed, Aug 06, 2014 at 04:25:25PM +0400, Pavel Emelyanov wrote:
> We already have a signals setup helper for this.
> 
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>

Acked-by: Andrew Vagin <avagin at parallels.com>

> ---
>  cr-restore.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 5757130..afdafd8 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1067,6 +1067,7 @@ static int criu_signals_setup(void)
>  {
>  	int ret;
>  	struct sigaction act;
> +	sigset_t blockmask;
>  
>  	ret = sigaction(SIGCHLD, NULL, &act);
>  	if (ret < 0) {
> @@ -1097,6 +1098,19 @@ static int criu_signals_setup(void)
>  		return -1;
>  	}
>  
> +	/*
> +	 * The block mask will be restored in sigreturn.
> +	 *
> +	 * TODO: This code should be removed, when a freezer will be added.
> +	 */
> +	sigfillset(&blockmask);
> +	sigdelset(&blockmask, SIGCHLD);
> +	ret = sigprocmask(SIG_BLOCK, &blockmask, NULL);
> +	if (ret < 0) {
> +		pr_perror("Can't block signals");
> +		return -1;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -1248,7 +1262,6 @@ static int restore_task_with_children(void *_arg)
>  	struct cr_clone_arg *ca = _arg;
>  	pid_t pid;
>  	int ret;
> -	sigset_t blockmask;
>  
>  	current = ca->item;
>  
> @@ -1315,19 +1328,6 @@ static int restore_task_with_children(void *_arg)
>  			goto err;
>  	}
>  
> -	/*
> -	 * The block mask will be restored in sigreturn.
> -	 *
> -	 * TODO: This code should be removed, when a freezer will be added.
> -	 */
> -	sigfillset(&blockmask);
> -	sigdelset(&blockmask, SIGCHLD);
> -	ret = sigprocmask(SIG_BLOCK, &blockmask, NULL);
> -	if (ret) {
> -		pr_perror("%d: Can't block signals", current->pid.virt);
> -		goto err;
> -	}
> -
>  	if (prepare_mappings(pid))
>  		goto err;
>  
> -- 
> 1.8.4.2
> 
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list