Subject: [PATCH 1/1] revert: fix BUG at criu/pstree.c:452

Not all the process which is dumped by criu is session leader, the
enhancing verification is annoying, because it causes many problems in
some testcases. Therefore, revert this bugfix.

If the bugfix is resumed, using `setsid` to start process is necessary,
and using `stdbuf -oL` to redirect standard output at the same time.

This bug detail sees #1332.

Revert "pstree: don't change sid/gid-s if current sid/gid is the same"
This reverts commit 90e03b1a1142ca40fb78de9eb04944ab51d06eeb.

Revert "pstree: check for pid collision before switching to new sid/gid"
This reverts commit 7e6a1a7011b404fbf0108b062bda118e9a696b60.
---
 criu/pstree.c | 37 ++++++++++---------------------------
 1 file changed, 10 insertions(+), 27 deletions(-)

diff --git a/criu/pstree.c b/criu/pstree.c
index d5080e515..bf09c761c 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -340,7 +340,6 @@ static int prepare_pstree_for_shell_job(pid_t pid)
 	pid_t current_gid = getpgid(pid);
 
 	struct pstree_item *pi;
-	struct pid *tmp;
 
 	pid_t old_sid;
 	pid_t old_gid;
@@ -348,7 +347,6 @@ static int prepare_pstree_for_shell_job(pid_t pid)
 	if (!opts.shell_job)
 		return 0;
 
-	/* root_item is a session leader */
 	if (root_item->sid == vpid(root_item))
 		return 0;
 
@@ -370,37 +368,22 @@ static int prepare_pstree_for_shell_job(pid_t pid)
 	 */
 
 	old_sid = root_item->sid;
-	if (old_sid != current_sid) {
-		pr_info("Migrating process tree (SID %d->%d)\n", old_sid, current_sid);
 
-		tmp = pstree_pid_by_virt(current_sid);
-		if (tmp) {
-			pr_err("Current sid %d intersects with pid (%d) in images\n", current_sid, tmp->state);
-			return -1;
-		}
+	pr_info("Migrating process tree (SID %d->%d)\n",
+		old_sid, current_sid);
 
-		for_each_pstree_item(pi) {
-			if (pi->sid == old_sid)
-				pi->sid = current_sid;
-		}
-
-		if (lookup_create_item(current_sid) == NULL)
-			return -1;
+	for_each_pstree_item(pi) {
+		if (pi->sid == old_sid)
+			pi->sid = current_sid;
 	}
 
-	/* root_item is a group leader */
-	if (root_item->pgid == vpid(root_item))
-		return 0;
-
 	old_gid = root_item->pgid;
-	if (old_gid != current_gid) {
-		pr_info("Migrating process tree (GID %d->%d)\n", old_gid, current_gid);
-
-		tmp = pstree_pid_by_virt(current_gid);
-		if (tmp) {
-			pr_err("Current gid %d intersects with pid (%d) in images\n", current_gid, tmp->state);
+	if (old_gid != vpid(root_item)) {
+		if (lookup_create_item(current_sid) == NULL)
 			return -1;
-		}
+
+		pr_info("Migrating process tree (GID %d->%d)\n",
+			old_gid, current_gid);
 
 		for_each_pstree_item(pi) {
 			if (pi->pgid == old_gid)
-- 
2.35.1