[CRIU] [PATCH] ensure SIGCHLD isn't inherited as blocked

Andrew Vagin avagin at odin.com
Fri Jun 5 06:56:17 PDT 2015


On Fri, Jun 05, 2015 at 07:48:13AM -0600, Tycho Andersen wrote:
> Use SIG_SETMASK instead of SIG_BLOCKMASK here in case the parent had SIGCHLD
> blocked. In this case if one of the criu threads has a problem, since the
> SIGCHLD is blocked, the restore simply hangs.
> 
Acked-by: Andrew Vagin <avagin at virtuozzo.com>

> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  cr-restore.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index aa00dc2..5a6347a 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1255,7 +1255,15 @@ static int criu_signals_setup(void)
>  	 */
>  	sigfillset(&blockmask);
>  	sigdelset(&blockmask, SIGCHLD);
> -	ret = sigprocmask(SIG_BLOCK, &blockmask, NULL);
> +
> +	/*
> +	 * Here we use SIG_SETMASK instead of SIG_BLOCK to avoid the case where
> +	 * we've been forked from a parent who had blocked SIGCHLD. If SIGCHLD
> +	 * is blocked when a task dies (e.g. if the task fails to restore
> +	 * somehow), we hang because our SIGCHLD handler is never run. Since we
> +	 * depend on SIGCHLD being unblocked, let's set the mask explicitly.
> +	 */
> +	ret = sigprocmask(SIG_SETMASK, &blockmask, NULL);
>  	if (ret < 0) {
>  		pr_perror("Can't block signals");
>  		return -1;
> -- 
> 2.1.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list