- ptrace_unlink(current);
- ptrace_unlink(leader);
- remove_parent(current);
- remove_parent(leader);
-
- switch_exec_pids(leader, current);
+ /* Become a process group leader with the old leader's pid.
+ * The old leader becomes a thread of the this thread group.
+ * Note: The old leader also uses this pid until release_task
+ * is called. Odd but simple and correct.
+ */
+ detach_pid(tsk, PIDTYPE_PID);
+ tsk->pid = leader->pid;
+ attach_pid(tsk, PIDTYPE_PID, tsk->pid);
+ transfer_pid(leader, tsk, PIDTYPE_PGID);
+ transfer_pid(leader, tsk, PIDTYPE_SID);
+ list_replace_rcu(&leader->tasks, &tsk->tasks);