[CRIU] [PATCH] restore: block SIGCHILD for sub-processes
Tycho Andersen
tycho.andersen at canonical.com
Mon Oct 5 06:03:45 PDT 2015
On Mon, Oct 05, 2015 at 02:56:06PM +0300, Andrey Vagin wrote:
> From: Andrew Vagin <avagin at openvz.org>
>
> Otherwise sigchld_handler() will call waitpid()
> and worries about unknown process.
>
> (00.333012) 1: kernel/hostname nr 15
> (00.333120) 1: kernel/domainname nr 6
> (00.335243) 1: Error (cr-restore.c:1225): BUG at cr-restore.c:1225
>
> Cc: Tycho Andersen <tycho.andersen at canonical.com>
Whoops, somehow I didn't hit this when I ran the tests, thanks:
Acked-by: Tycho Andersen <tycho.andersen at canonical.com>
> Reported-by: Mr Jenkins
> Signed-off-by: Andrew Vagin <avagin at openvz.org>
> ---
> sysctl.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/sysctl.c b/sysctl.c
> index e9fdf40..9a4bd1a 100644
> --- a/sysctl.c
> +++ b/sysctl.c
> @@ -196,6 +196,7 @@ static int __userns_sysctl_op(void *arg, int unused, pid_t pid)
> struct sysctl_userns_req *userns_req = arg;
> int op = userns_req->op;
> struct sysctl_req *req, **reqs = NULL;
> + sigset_t blockmask, oldmask;
> pid_t worker;
>
> // fix up the pointer
> @@ -266,6 +267,16 @@ static int __userns_sysctl_op(void *arg, int unused, pid_t pid)
> req = (struct sysctl_req *) (((char *) req) + total_len);
> }
>
> + /*
> + * Don't let the sigchld_handler() mess with us
> + * calling waitpid() on the exited worker. The
> + * same is done in cr_system().
> + */
> +
> + sigemptyset(&blockmask);
> + sigaddset(&blockmask, SIGCHLD);
> + sigprocmask(SIG_BLOCK, &blockmask, &oldmask);
> +
> worker = fork();
> if (worker < 0)
> goto out;
> @@ -310,6 +321,8 @@ static int __userns_sysctl_op(void *arg, int unused, pid_t pid)
> ret = 0;
>
> out:
> + sigprocmask(SIG_BLOCK, &oldmask, NULL);
> +
> if (fds) {
> for (i = 0; i < userns_req->nr_req; i++) {
> if (fds[i] < 0)
> --
> 2.4.3
>
More information about the CRIU
mailing list