mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +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 de71bc69170cfeceb24bddd431ad10b8ea607d42 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:
parent
adc63c73d5
commit
e50d0e7c6f
25
cr-restore.c
25
cr-restore.c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user