From: Oleg Nesterov daemonize() calls set_special_pids(1,1), while init and kernel threads spawned from init/main.c:init() run with 0,0 special pids. This patch changes INIT_SIGNALS() so that that they run with ->pgrp == ->session == 1 also. This patch relies on fact that swapper's pid == 1. Now we have no hashed zero pids in pid_hash[]. User-space visibible change is that now /sbin/init runs with (1,1) special pids and becomes a session leader. Quoting Eric W. Biederman: > > daemonize consuming pids (1,1) then consumes pgrp 1. So that when > /sbin/init calls setsid() it thinks /sbin/init is a process group > leader and setsid() fails. So /sbin/init wants pgrp 1 session 1 > but doesn't get it. I am pretty certain daemonize did not exist so > /sbin/init got pgrp 1 session 1 in 2.4. > > That is the bug that is being fixed. > > This patch takes things one step farther and essentially calls > setsid() for pid == 1 before init is execed. That is new behavior > but it cleans up the kernel as we now do not need to support the > case of a process without a process group or a session. > > The only process that could have possibly cared was /sbin/init > and it already calls setsid() because it doesn't want that. > > If this was going to break anything noticeable the change in behavior > from 2.4 to 2.6 would have already done that. Signed-off-by: Oleg Nesterov Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton --- include/linux/init_task.h | 2 ++ 1 files changed, 2 insertions(+) diff -puN include/linux/init_task.h~pidhash-dont-use-zero-pids include/linux/init_task.h --- devel/include/linux/init_task.h~pidhash-dont-use-zero-pids 2006-02-04 12:58:40.000000000 -0800 +++ devel-akpm/include/linux/init_task.h 2006-02-04 12:58:40.000000000 -0800 @@ -62,6 +62,8 @@ .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ .rlim = INIT_RLIMITS, \ + .pgrp = 1, \ + .session = 1, \ } #define INIT_SIGHAND(sighand) { \ _