[CRIU] [PATCH 12/13] restore: set up a handler for collecting signals from zombies

Andrey Vagin avagin at openvz.org
Thu Dec 20 06:54:20 EST 2012


All pending signals are restored by another code.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/types.h |  2 ++
 pie/restorer.c  | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/types.h b/include/types.h
index 9b7884f..768da7c 100644
--- a/include/types.h
+++ b/include/types.h
@@ -103,6 +103,8 @@ typedef struct {
 	rt_sigset_t	rt_sa_mask;
 } rt_sigaction_t;
 
+#define SA_RESTORER     0x04000000
+
 #define _KNSIG           64
 # define _NSIG_BPW      64
 
diff --git a/pie/restorer.c b/pie/restorer.c
index 4d23619..df96416 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <sched.h>
 #include <sys/resource.h>
+#include <signal.h>
 
 #include "compiler.h"
 #include "types.h"
@@ -38,6 +39,20 @@
 static struct task_entries *task_entries;
 static futex_t thread_inprogress;
 
+asm (								\
+	"nop\n"							\
+	".align 16\n"						\
+	"__cr_restore_rt:\n"					\
+	"       movq $"__stringify(__NR_rt_sigreturn)", %rax\n"	\
+	"       syscall"					\
+);
+extern void cr_restore_rt (void) asm ("__cr_restore_rt")
+			__attribute__ ((visibility ("hidden")));
+
+static void sigzombie_handler(int signal, siginfo_t *siginfo, void *data)
+{
+}
+
 static void sigchld_handler(int signal, siginfo_t *siginfo, void *data)
 {
 	char *r;
@@ -782,6 +797,12 @@ long __export_restore_task(struct task_restore_core_args *args)
 
 	restore_finish_stage(CR_STATE_RESTORE);
 
+	sys_sigaction(SIGCHLD, NULL, &act, sizeof(rt_sigset_t));
+	act.rt_sa_handler = sigzombie_handler;
+	act.rt_sa_flags |= SA_SIGINFO;
+	act.rt_sa_restorer = cr_restore_rt;
+	sys_sigaction(SIGCHLD, &act, NULL, sizeof(rt_sigset_t));
+
 	sys_sigaction(SIGCHLD, &args->sigchld_act, NULL, sizeof(rt_sigset_t));
 
 	ret = restore_signals(args->siginfo, args->siginfo_nr, 1);
-- 
1.7.11.7



More information about the CRIU mailing list