[CRIU] [PATCH 08/10] restore: set up a handler for collecting signals from zombies (v2)
Andrey Vagin
avagin at openvz.org
Wed Mar 6 16:00:40 EST 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/x86/include/asm/types.h | 2 ++
arch/x86/syscall-common-x86-64.S | 5 +++++
pie/restorer.c | 14 ++++++++++++++
3 files changed, 21 insertions(+)
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index d33dfb5..2361a57 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/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/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 d88fc7b..93c771f 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);
+ 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