From: Eric W. Biederman With the bug fixes from killing session == 0 and pgrp == 0 we have essentially made pid == 1 a session leader. However reading through the code I can see nothing, that sets the session->leader flag. In fact we actively clear it in all cases during clone. And setsid will fail to set it because the session == 1 and process group == 1 already exist. So this patch forces the session leader flag and for good measure the pgrp, session and tty of init as well. Signed-off-by: Eric W. Biederman Cc: Oleg Nesterov Signed-off-by: Andrew Morton --- kernel/fork.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff -puN kernel/fork.c~fork-allow-init-to-become-a-session-leader kernel/fork.c --- devel/kernel/fork.c~fork-allow-init-to-become-a-session-leader 2006-02-27 20:58:31.000000000 -0800 +++ devel-akpm/kernel/fork.c 2006-02-27 20:58:31.000000000 -0800 @@ -1177,9 +1177,16 @@ static task_t *copy_process(unsigned lon __ptrace_link(p, current->parent); if (thread_group_leader(p)) { - p->signal->tty = current->signal->tty; - p->signal->pgrp = process_group(current); - p->signal->session = current->signal->session; + if (unlikely(p->pid == 1)) { + p->signal->tty = NULL; + p->signal->leader = 1; + p->signal->pgrp = 1; + p->signal->session = 1; + } else { + p->signal->tty = current->signal->tty; + p->signal->pgrp = process_group(current); + p->signal->session = current->signal->session; + } attach_pid(p, PIDTYPE_PGID, process_group(p)); attach_pid(p, PIDTYPE_SID, p->signal->session); _