pstree: allow shelljob to inherit sid from criu process again

Submitted by Pavel Tikhomirov on July 26, 2017, 8:37 a.m.


Message ID
State Accepted
Series "pstree: allow shelljob to inherit sid from criu process again"
Commit 18d3b706f8e182edc1fa7ac9dcbb2d83559206e8
Headers show

Commit Message

Pavel Tikhomirov July 26, 2017, 8:37 a.m.
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 <>
 criu/pstree.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

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))
+				/* 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;


Pavel Emelianov Aug. 15, 2017, 10:23 a.m.