Date: Tue, 08 Jun 1999 02:40:57 +0100 From: Brian Somers <brian@Awfulhak.org> To: "Eugene M. Kim" <gene@nttmcl.com> Cc: hackers@freebsd.org Subject: Re: Session leader releasing the ctty Message-ID: <199906080140.CAA14092@keep.lan.Awfulhak.org> In-Reply-To: Your message of "Mon, 07 Jun 1999 17:14:48 PDT." <Pine.BSF.4.10.9906071658080.93580-100000@firee.ia.cp>
next in thread | previous in thread | raw e-mail | index | archive | help
> Hello, > > I'm having a trouble programming a special login shell, and would like > to hear any opinions on this. > > I want this shell (which automatically becomes a session leader) to > release its ctty but remain unterminated (the ctty must be taken by its > child). However, there seems to be no easy way to do this; termios(4) > says one must call setsid() to release its ctty, but setsid(2) says the > call will fail if the caller is already a session leader. > > Would there be any other way for a session leader to release its ctty > without terminating itself? TIA. You need to also drop your process id so that you're not the owner of the process group that the terminal points at. Check bundle_setsid() in src/usr.sbin/ppp/bundle.c. A second fork() is done here because the parent may continue and doesn't want to figure out how to reap the child - you probably don't need this if the original process is going to go away soon anyway. > Cheers, > Eugene Kim > > PS. I'm now using a workaround that the shell will forward the SIGHUP > that it received because it's a session leader, but this isn't a clean > way. :-p > > -- > Eugene M. Kim NTT Multimedia Communications Laboratories > Software Developer 250 Cambridge Avenue, Suite 205 > +1 650 833 3630 (Voice) Palo Alto, CA 94040, USA > +1 650 833 3633 (Fax) mailto:gene@nttmcl.com -- Brian <brian@Awfulhak.org> <brian@FreeBSD.org> <http://www.Awfulhak.org> <brian@OpenBSD.org> Don't _EVER_ lose your sense of humour ! <brian@uk.FreeBSD.org> 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?199906080140.CAA14092>