From owner-freebsd-hackers Thu Nov 5 22:00:35 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA20863 for freebsd-hackers-outgoing; Thu, 5 Nov 1998 22:00:35 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from gatekeeper.tsc.tdk.com (gatekeeper.tsc.tdk.com [207.113.159.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA20858 for ; Thu, 5 Nov 1998 22:00:34 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from sunrise.gv.tsc.tdk.com (root@sunrise.gv.tsc.tdk.com [192.168.241.191]) by gatekeeper.tsc.tdk.com (8.8.8/8.8.8) with ESMTP id WAA17262; Thu, 5 Nov 1998 22:00:19 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from salsa.gv.tsc.tdk.com (salsa.gv.tsc.tdk.com [192.168.241.194]) by sunrise.gv.tsc.tdk.com (8.8.5/8.8.5) with ESMTP id WAA28928; Thu, 5 Nov 1998 22:00:18 -0800 (PST) Received: (from gdonl@localhost) by salsa.gv.tsc.tdk.com (8.8.5/8.8.5) id WAA16417; Thu, 5 Nov 1998 22:00:16 -0800 (PST) From: Don Lewis Message-Id: <199811060600.WAA16417@salsa.gv.tsc.tdk.com> Date: Thu, 5 Nov 1998 22:00:16 -0800 In-Reply-To: Luoqi Chen "Re: question about getsid()" (Oct 24, 2:44am) X-Mailer: Mail User's Shell (7.2.6 alpha(3) 7/19/95) To: Luoqi Chen , Don.Lewis@tsc.tdk.com, hackers@FreeBSD.ORG, jau@jau.tmt.tele.fi Subject: Re: question about getsid() Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Oct 24, 2:44am, Luoqi Chen wrote: } Subject: Re: question about getsid() } > getsid() needs to verify s_leader is not NULL before dereferencing it, } > but what should getsid() return if there is no session leader? } > } If the session leader is gone, the session losts the ability to acquire } a controlling terminal, which is the sole purpose of its existence. } This session should be disbanded, and member process groups join session 0. I can see three possible implementations. The first two implementations are literally what you describe. In the first, all the process groups need to be visited and any that reference this session need have their pg_session pointer changed to point to session0, and the reference counts updated. This could be expensive if there are a lot of process groups. In the second implementation, all of the process groups that belong to a session would be linked together and hung off the session structure. When the session leader exits, it would only be necessary to traverse this short list. This is more expensive in terms of memory consumption, but it would be possible to eliminate the session reference count. Another disadvantage would be the expense of maintaining the session0 process group list, since this list could be quite long. The simple but hackish thing to do would be to change getsid() to return session0.s_leader->p_pid if p->p_pgrp->pg_session->s_leader is NULL, and reclaim the abandoned session when all the process groups that reference it are gone. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message