From 3569b51eef0ba5dd4dd70f306319b29293189f43 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 28 Sep 2016 11:22:29 +0300 Subject: [PATCH] infect: Place sigchild handler on ictx To track victim health state criu sets up the sigchild handler. So will have to do the compel, but the ability to request for own handler would be required. Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- criu/include/parasite-syscall.h | 2 ++ criu/parasite-syscall.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h index b1ca5024f..d0ab8c61d 100644 --- a/criu/include/parasite-syscall.h +++ b/criu/include/parasite-syscall.h @@ -29,6 +29,8 @@ struct thread_ctx { struct infect_ctx { int *p_sock; unsigned long flags; /* fine-tune (e.g. faults) */ + + void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */ }; #define INFECT_NO_MEMFD 0x1 /* don't use memfd() */ diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c index c485391d8..d447c8ee1 100644 --- a/criu/parasite-syscall.c +++ b/criu/parasite-syscall.c @@ -411,10 +411,10 @@ static void sigchld_handler(int signal, siginfo_t *siginfo, void *data) exit(1); } -static int setup_child_handler() +static int setup_child_handler(struct parasite_ctl *ctl) { struct sigaction sa = { - .sa_sigaction = sigchld_handler, + .sa_sigaction = ctl->ictx.child_handler, .sa_flags = SA_SIGINFO | SA_RESTART, }; @@ -524,7 +524,7 @@ static int parasite_init_daemon(struct parasite_ctl *ctl) goto err; /* after this we can catch parasite errors in chld handler */ - if (setup_child_handler()) + if (setup_child_handler(ctl)) goto err; regs = ctl->orig.regs; @@ -1480,6 +1480,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, if (!ctl) return NULL; + ctl->ictx.child_handler = sigchld_handler; ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk; if (fault_injected(FI_NO_MEMFD))