[CRIU] [PATCH 4/8] sig: Don't reset CHLD handler to old action, DFL it
Pavel Emelyanov
xemul at parallels.com
Wed Aug 6 05:24:52 PDT 2014
The whole idea behind this code was to stop receiving CHLD from
restored tasks after resume. The comment about this is done for
scripts is wrong (we call more scripts before this).
And since CHLD handler makes little sence after exec, it's easier
just to reset one to default action at the end.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
cr-restore.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index 5aa5472..f27e1f8 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1475,10 +1475,18 @@ detach:
}
}
+static void ignore_kids(void)
+{
+ struct sigaction sa = { .sa_handler = SIG_DFL };
+
+ if (sigaction(SIGCHLD, &sa, NULL) < 0)
+ pr_perror("Restoring CHLD sigaction failed");
+}
+
static int restore_root_task(struct pstree_item *init)
{
int ret, fd;
- struct sigaction act, old_act;
+ struct sigaction act;
fd = open("/proc", O_DIRECTORY | O_RDONLY);
if (fd < 0) {
@@ -1514,7 +1522,7 @@ static int restore_root_task(struct pstree_item *init)
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGCHLD);
- ret = sigaction(SIGCHLD, &act, &old_act);
+ ret = sigaction(SIGCHLD, &act, NULL);
if (ret < 0) {
pr_perror("sigaction() failed");
return -1;
@@ -1588,13 +1596,6 @@ static int restore_root_task(struct pstree_item *init)
if (ret < 0)
goto out_kill;
- /* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
- ret = sigaction(SIGCHLD, &old_act, NULL);
- if (ret < 0) {
- pr_perror("sigaction() failed");
- goto out_kill;
- }
-
ret = run_scripts("post-restore");
if (ret != 0) {
pr_err("Aborting restore due to script ret code %d\n", ret);
@@ -1607,6 +1608,12 @@ static int restore_root_task(struct pstree_item *init)
network_unlock();
/*
+ * Stop getting sigchld, after we resume the tasks they
+ * may start to exit poking criu in vain.
+ */
+ ignore_kids();
+
+ /*
* -------------------------------------------------------------
* Below this line nothing can fail, because network is unlocked
*/
--
1.8.4.2
More information about the CRIU
mailing list