Date: Wed, 21 Oct 1998 16:19:28 +0300 (EET DST) From: "Jukka A. Ukkonen" <jau@jau.tmt.tele.fi> To: hackers@FreeBSD.ORG Subject: question about getsid() Message-ID: <199810211319.QAA15509@jau.tmt.tele.fi>
next in thread | raw e-mail | index | archive | help
Howdy, everybody! When looking at the 3.0 getsid() code in kern_prot.c I became a little hesitant about whether the following code will always work... int getsid(p, uap) struct proc *p; struct getsid_args *uap; { if (uap->pid == 0) goto found; if ((p == pfind(uap->pid)) == 0) return ESRCH; found: p->p_retval[0] = p->p_pgrp->pg_session->s_leader->p_pid; return 0; } What will happen if the process leader has already died? Will the original session leader's process struct still be around available for reference or will the code fail? My own implementation of the same thing added a new field `s_sid' to the session struct, because I suspected problems doing it the way the current 3.0 code does. This new field is in my version initialized during setsid() using the PID of the session leader, but the code does not assume the process struct for the session leader being available later, because `s_sid' content will be returned by getsid(). Maybe my version has been playing extra safe in vain, but at least that way there is no way to make the kernel panic just by calling getsid(). Now I would like to know whether it had been quite as safe to write my own version the way it is now done in 3.0 or is 3.0 relying on something which is not really guaranteed. Any comments? Cheers, // jau .--- ..- -.- -.- .- .- .-.-.- ..- -.- -.- --- -. . -. / Jukka A. Ukkonen, Internet Services R&D / Sonera Ltd. /__ M.Sc. (sw-eng & cs) (Phone) +358-2040-4025 / Internet: Jukka.Ukkonen@sonera.fi (Fax) +358-2040-64724 / Internet: jau@iki.fi (Mobile) +358-400-606671 v Internet: ukkonen@nic.funet.fi (Home&Fax) +358-9-6215280 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810211319.QAA15509>