mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
sig: Instantly drop SA_NOCLDSTOP for swrk_restore
We tune the CHLD handler if we're restoring root task as sibling. This tuning is better to be done with one sigaction() call, rather than two. First, it's shorter and the second -- it will allow us to move the whole criu signalling setup into one helper. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Andrew Vagin <avagin@parallels.com>
This commit is contained in:
29
cr-restore.c
29
cr-restore.c
@@ -1503,6 +1503,18 @@ static int restore_root_task(struct pstree_item *init)
|
||||
}
|
||||
|
||||
act.sa_flags |= SA_NOCLDSTOP | SA_SIGINFO | SA_RESTART;
|
||||
if (opts.swrk_restore)
|
||||
/*
|
||||
* Root task will be our sibling. This means, that
|
||||
* we will not notice when (if) it dies in SIGCHLD
|
||||
* handler, but we should. To do this -- attach to
|
||||
* the guy with ptrace (below) and (!) make the kernel
|
||||
* deliver us the signal when it will get stopped.
|
||||
* It will in case of e.g. segfault before handling
|
||||
* the signal.
|
||||
*/
|
||||
act.sa_flags &= ~SA_NOCLDSTOP;
|
||||
|
||||
act.sa_sigaction = sigchld_handler;
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaddset(&act.sa_mask, SIGCHLD);
|
||||
@@ -1550,23 +1562,6 @@ static int restore_root_task(struct pstree_item *init)
|
||||
return -1;
|
||||
|
||||
if (opts.swrk_restore) {
|
||||
/*
|
||||
* Root task is not our sibling. This means, that
|
||||
* we will not notice when (if) it dies in SIGCHLD
|
||||
* handler, but we should. To do this -- attach to
|
||||
* the guy with ptrace and (!) make the kernel
|
||||
* deliver us the signal when it will get stopped.
|
||||
* It will in case of e.g. segfault before handling
|
||||
* the signal.
|
||||
*/
|
||||
|
||||
act.sa_flags &= ~SA_NOCLDSTOP;
|
||||
ret = sigaction(SIGCHLD, &act, NULL);
|
||||
if (ret < 0) {
|
||||
pr_perror("sigaction() failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (ptrace(PTRACE_SEIZE, init->pid.real, 0, 0)) {
|
||||
pr_perror("Can't attach to init");
|
||||
goto out;
|
||||
|
Reference in New Issue
Block a user