Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030299AbWBHRLn (ORCPT ); Wed, 8 Feb 2006 12:11:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030346AbWBHRLn (ORCPT ); Wed, 8 Feb 2006 12:11:43 -0500 Received: from mail.tv-sign.ru ([213.234.233.51]:47841 "EHLO several.ru") by vger.kernel.org with ESMTP id S1030299AbWBHRLm (ORCPT ); Wed, 8 Feb 2006 12:11:42 -0500 Message-ID: <43EA386B.D1A20AEB@tv-sign.ru> Date: Wed, 08 Feb 2006 21:28:59 +0300 From: Oleg Nesterov X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.20 i686) X-Accept-Language: en MIME-Version: 1.0 To: "Eric W. Biederman" Cc: Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] fork: Allow init to become a session leader. References: Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1675 Lines: 37 "Eric W. Biederman" wrote: > > 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. > > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1179,9 +1179,16 @@ static task_t *copy_process(unsigned lon > attach_pid(p, PIDTYPE_PID, p->pid); > attach_pid(p, PIDTYPE_TGID, p->tgid); > 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; Isn't it enough to just set current->signal->leader = 1 in init/main.c:init() ? This process was already forked with (1,1) special pids and ->tty == NULL. Oleg. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/