[CRIU] [PATCH 09/13] restore: set up a handler for collecting signals from zombies (v2)

Andrey Vagin avagin at openvz.org
Fri Mar 15 09:49:20 EDT 2013


All pending signals are restored by another code.

In this moment all crtools VMA-s are unmapped, so we need to have
own sa_restorer.

Alexander, could you help me with ARM? I found in glibc sources, that
sa_restoer should look like this:

ports/sysdeps/unix/sysv/linux/arm/sigrestorer.S
....
ENTRY(__cr_restore_rt)
        CFI
        mov     r7, $SYS_ify(rt_sigreturn)
        swi     0x0
        .fnend
END(__cr_restore_rt)

v2: Move architecture-dependent code in the proper place

Cc: Alexander Kartashov <alekskartashov at parallels.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/arm/include/asm/types.h     |  2 ++
 arch/x86/include/asm/types.h     |  2 ++
 arch/x86/syscall-common-x86-64.S |  5 +++++
 pie/restorer.c                   | 14 ++++++++++++++
 4 files changed, 23 insertions(+)

diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
index 715d1c8..5a97cdf 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/asm/types.h
@@ -99,6 +99,8 @@ static inline void ksigfillset(k_rtsigset_t *set)
 		set->sig[i] = (unsigned long)-1;
 }
 
+#define SA_RESTORER	0x04000000
+
 typedef struct {
 	rt_sighandler_t	rt_sa_handler;
 	unsigned long	rt_sa_flags;
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index 79fd448..83e351b 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -108,6 +108,8 @@ static inline void ksigfillset(k_rtsigset_t *set)
 		set->sig[i] = (unsigned long)-1;
 }
 
+#define SA_RESTORER	0x04000000
+
 typedef struct {
 	rt_sighandler_t	rt_sa_handler;
 	unsigned long	rt_sa_flags;
diff --git a/arch/x86/syscall-common-x86-64.S b/arch/x86/syscall-common-x86-64.S
index a549207..b93c312 100644
--- a/arch/x86/syscall-common-x86-64.S
+++ b/arch/x86/syscall-common-x86-64.S
@@ -14,3 +14,8 @@ ENTRY(__syscall_common)
 	syscall
 	ret
 END(__syscall_common)
+
+ENTRY(__cr_restore_rt)
+	movq $__NR_rt_sigreturn, %rax
+	syscall
+END(__cr_restore_rt)
diff --git a/pie/restorer.c b/pie/restorer.c
index 3282060..5530ac8 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -11,6 +11,7 @@
 #include <unistd.h>
 #include <sched.h>
 #include <sys/resource.h>
+#include <signal.h>
 
 #include "compiler.h"
 #include "asm/types.h"
@@ -39,6 +40,13 @@
 static struct task_entries *task_entries;
 static futex_t thread_inprogress;
 
+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;
@@ -727,6 +735,12 @@ long __export_restore_task(struct task_restore_core_args *args)
 
 	restore_finish_stage(CR_STATE_RESTORE);
 
+	ksigfillset(&act.rt_sa_mask);
+	act.rt_sa_handler = sigzombie_handler;
+	act.rt_sa_flags = SA_SIGINFO | SA_RESTORER | SA_RESTART;
+	act.rt_sa_restorer = cr_restore_rt;
+	sys_sigaction(SIGCHLD, &act, NULL, sizeof(k_rtsigset_t));
+
 	sys_sigaction(SIGCHLD, &args->sigchld_act, NULL, sizeof(k_rtsigset_t));
 
 	ret = restore_signals(args->siginfo, args->siginfo_nr, 1);
-- 
1.7.11.7



More information about the CRIU mailing list