Commit e50d0e7c authored by Pavel Emelyanov's avatar Pavel Emelyanov

sig: Don't reset CHLD handler to old action, DFL it

The whole idea behind this code was to stop receiving CHLD from
restored tasks after resume. The comment about this is done for
scripts is wrong (we call more scripts before this) because
sigchld_handler() knows about scripts:

commit de71bc69
	 exit = (siginfo->si_code == CLD_EXITED);
	 status = siginfo->si_status;
	+
	+       /* skip scripts */
	+       if (!current && root_item->pid.real != pid) {
	+               pid = waitpid(root_item->pid.real, &status, WNOHANG);
	+               if (pid <= 0)
	+                       return;
	+       }

And since CHLD handler makes little sence after exec, it's easier
just to reset one to default action at the end.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
parent adc63c73
......@@ -1480,10 +1480,18 @@ detach:
}
}
static void ignore_kids(void)
{
struct sigaction sa = { .sa_handler = SIG_DFL };
if (sigaction(SIGCHLD, &sa, NULL) < 0)
pr_perror("Restoring CHLD sigaction failed");
}
static int restore_root_task(struct pstree_item *init)
{
int ret, fd;
struct sigaction act, old_act;
struct sigaction act;
fd = open("/proc", O_DIRECTORY | O_RDONLY);
if (fd < 0) {
......@@ -1519,7 +1527,7 @@ static int restore_root_task(struct pstree_item *init)
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGCHLD);
ret = sigaction(SIGCHLD, &act, &old_act);
ret = sigaction(SIGCHLD, &act, NULL);
if (ret < 0) {
pr_perror("sigaction() failed");
return -1;
......@@ -1593,13 +1601,6 @@ static int restore_root_task(struct pstree_item *init)
if (ret < 0)
goto out_kill;
/* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
ret = sigaction(SIGCHLD, &old_act, NULL);
if (ret < 0) {
pr_perror("sigaction() failed");
goto out_kill;
}
ret = run_scripts("post-restore");
if (ret != 0) {
pr_err("Aborting restore due to script ret code %d\n", ret);
......@@ -1611,6 +1612,12 @@ static int restore_root_task(struct pstree_item *init)
/* Unlock network before disabling repair mode on sockets */
network_unlock();
/*
* Stop getting sigchld, after we resume the tasks they
* may start to exit poking criu in vain.
*/
ignore_kids();
/*
* -------------------------------------------------------------
* Below this line nothing can fail, because network is unlocked
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment