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))