[CRIU] [PATCH] restore: --restore-detached implies CLONE_PARENT

Tycho Andersen tycho.andersen at canonical.com
Wed Aug 13 10:23:49 PDT 2014


We need to use CLONE_PARENT to prevent processes from immediately dying due to
pdeath_sig when they are restored in detached mode.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 cr-restore.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 2bc98e8..b24fa9e 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1592,15 +1592,19 @@ static int restore_root_task(struct pstree_item *init)
 	 * In that case create the root task as the child one to+
 	 * the caller. This is the only way to correctly restore the
 	 * pdeath_sig of the root task. But also looks nice.
+	 *
+	 * Alternatively, if we are --restore-detached, a similar trick is
+	 * needed to correctly restore pdeath_sig and prevent processes from
+	 * dying once restored.
 	 */
-	if (opts.swrk_restore)
+	if (opts.swrk_restore || opts.restore_detach)
 		init->rst->clone_flags |= CLONE_PARENT;
 
 	ret = fork_with_pid(init);
 	if (ret < 0)
 		return -1;
 
-	if (opts.swrk_restore) {
+	if (opts.swrk_restore || opts.restore_detach) {
 		if (ptrace(PTRACE_SEIZE, init->pid.real, 0, 0)) {
 			pr_perror("Can't attach to init");
 			goto out;
-- 
1.9.1



More information about the CRIU mailing list