[CRIU] [PATCH] pstree: allow shelljob to inherit sid from criu process again

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Wed Jul 26 11:37:00 MSK 2017


In commit 8ce156970cb1 ("pstree: rework init reparent handling for pid
namespaces") I've changed session leader lookup to walk up untill
session leader, in sid inheritance check, not as before to just any
same session process. So we need to allow external sid to be inherited
explicitly for shell jobs.

With these fix I manage to c/r your example fine.

Note: for shell jobs with nested pidnses we need also "[PATCH 04/10]
pstree: add prepare_pstree_leaders to create sid/pgid helpers in
advance" which is in crml now, to prevent creating session helpers
for processes which want to inherit sid from criu process. For non
nestedns case we are fine.

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/pstree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/criu/pstree.c b/criu/pstree.c
index 23f0a62..7ecdba0 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -1133,6 +1133,11 @@ static int prepare_pstree_ids(void)
 				if (equal_pid(parent->pid, item->sid))
 					break;
 
+				/* Shell job's root_task inherits sid from criu */
+				if (opts.shell_job && parent == root_item && !is_session_leader(root_item)
+						&& equal_pid(parent->sid, item->sid))
+					break;
+
 				/* Inherited sid from parent */
 				if (equal_pid(parent->sid, item->sid)) {
 					parent = parent->parent;
-- 
2.9.4



More information about the CRIU mailing list