2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

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 de71bc6917
	 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: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
This commit is contained in:
Pavel Emelyanov
2014-08-06 16:24:52 +04:00
parent adc63c73d5
commit e50d0e7c6f

View File

@@ -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) static int restore_root_task(struct pstree_item *init)
{ {
int ret, fd; int ret, fd;
struct sigaction act, old_act; struct sigaction act;
fd = open("/proc", O_DIRECTORY | O_RDONLY); fd = open("/proc", O_DIRECTORY | O_RDONLY);
if (fd < 0) { if (fd < 0) {
@@ -1519,7 +1527,7 @@ static int restore_root_task(struct pstree_item *init)
sigemptyset(&act.sa_mask); sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGCHLD); sigaddset(&act.sa_mask, SIGCHLD);
ret = sigaction(SIGCHLD, &act, &old_act); ret = sigaction(SIGCHLD, &act, NULL);
if (ret < 0) { if (ret < 0) {
pr_perror("sigaction() failed"); pr_perror("sigaction() failed");
return -1; return -1;
@@ -1593,13 +1601,6 @@ static int restore_root_task(struct pstree_item *init)
if (ret < 0) if (ret < 0)
goto out_kill; 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"); ret = run_scripts("post-restore");
if (ret != 0) { if (ret != 0) {
pr_err("Aborting restore due to script ret code %d\n", ret); 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 */ /* Unlock network before disabling repair mode on sockets */
network_unlock(); 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 * Below this line nothing can fail, because network is unlocked