[CRIU] [PATCHv0 1/2] restorer: implement restore of ps tree in stopped state

Eugene Batalov eabatalov89 at gmail.com
Mon May 2 07:57:28 PDT 2016


From: Kravchenko Dmitrii <equivalence1 at gmail.com>

This patch adds implementation of --leave-stopped option
to CRIU restore cmd. If --leave-stopped is passed then
each process in ps tree gets SIGSTOP before detaching
from it.

Signed-off-by: Kravchenko Dmitrii <equivalence1 at gmail.com>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 criu/cr-restore.c |  3 ++-
 criu/crtools.c    | 10 ++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 0c6a828..4824716 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1817,7 +1817,8 @@ static void finalize_restore(void)
 
 		xfree(ctl);
 
-		if (item->state == TASK_STOPPED)
+		if ((item->state == TASK_STOPPED) ||
+				(opts.final_state == TASK_STOPPED))
 			kill(item->pid.real, SIGSTOP);
 	}
 }
diff --git a/criu/crtools.c b/criu/crtools.c
index 537bcc9..93a1ebe 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -631,6 +631,16 @@ int main(int argc, char *argv[], char *envp[])
 			return 1;
 	}
 
+	/*
+	 * When a process group becomes an orphan,
+	 * its processes are sent a SIGHUP signal
+	 */
+	if (!strcmp(argv[optind], "restore") &&
+			opts.restore_detach &&
+			opts.final_state == TASK_STOPPED &&
+			opts.shell_job)
+		pr_warn("Stopped and detached shell job will get SIGHUP from OS.");
+
 	if (chdir(work_dir)) {
 		pr_perror("Can't change directory to %s", work_dir);
 		return 1;
-- 
1.9.1



More information about the CRIU mailing list