[CRIU] Re: [PATCH cr 04/10] restore: add interface for creating
helper tasks (v2)
Pavel Emelyanov
xemul at parallels.com
Tue Jun 19 14:28:17 EDT 2012
> @@ -341,8 +341,28 @@ err:
>
> static int restore_one_alive_task(int pid)
> {
> + struct pstree_item *pi;
> pr_info("Restoring resources\n");
>
> + list_for_each_entry(pi, &me->children, list) {
> + int status, ret;
> +
> + if (pi->state != TASK_HELPER)
> + continue;
> +
> + ret = waitpid(pi->pid, &status, 0);
> + if (ret == -1) {
> + pr_err("waitpid(%d) failed\n", pi->pid);
> + return -1;
> + }
> +
> + if (!WIFEXITED(status) || WEXITSTATUS(status)) {
> + pr_err("%d exited with non-zero code (%d,%d)", pi->pid,
> + WEXITSTATUS(status), WTERMSIG(status));
> + return -1;
> + }
> + }
Plz put this into a helper fn with a comment about why we do it.
> +
> if (prepare_fds(me))
> return -1;
>
> @@ -557,6 +587,16 @@ err:
>
> static void sigchld_handler(int signal, siginfo_t *siginfo, void *data)
> {
> + struct pstree_item *pi;
> +
> + if (me)
> + list_for_each_entry(pi, &me->children, list) {
> + if (pi->state != TASK_HELPER)
> + continue;
> + if (pi->pid == siginfo->si_pid)
> + return;
> + }
Same here -- move to a helper with a comment.
> +
> if (siginfo->si_code & CLD_EXITED)
> pr_err("%d exited, status=%d\n",
> siginfo->si_pid, siginfo->si_status);
> @@ -704,7 +744,7 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
> return -1;
> }
>
> - act.sa_flags |= SA_NOCLDWAIT | SA_NOCLDSTOP | SA_SIGINFO | SA_RESTART;
> + act.sa_flags |= SA_NOCLDSTOP | SA_SIGINFO | SA_RESTART;
Plz, explain this hunk.
> act.sa_sigaction = sigchld_handler;
> ret = sigaction(SIGCHLD, &act, &old_act);
> if (ret < 0) {
More information about the CRIU
mailing list