[CRIU] [PATCH 3/8] sig: Instantly drop SA_NOCLDSTOP for swrk_restore
Pavel Emelyanov
xemul at parallels.com
Wed Aug 6 05:24:36 PDT 2014
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 at parallels.com>
---
cr-restore.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index e34e8a6..5aa5472 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1498,6 +1498,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);
@@ -1545,23 +1557,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;
--
1.8.4.2
More information about the CRIU
mailing list