From owner-freebsd-hackers Mon Jun 7 19: 1:27 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from awfulhak.org (awfulhak.force9.co.uk [195.166.136.63]) by hub.freebsd.org (Postfix) with ESMTP id 37CDE1536E for ; Mon, 7 Jun 1999 19:00:26 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from keep.lan.Awfulhak.org (keep.lan.Awfulhak.org [172.16.0.8]) by awfulhak.org (8.9.3/8.9.3) with ESMTP id CAA25402; Tue, 8 Jun 1999 02:41:40 +0100 (BST) (envelope-from brian@lan.awfulhak.org) Received: from keep.lan.Awfulhak.org (localhost [127.0.0.1]) by keep.lan.Awfulhak.org (8.9.3/8.9.3) with ESMTP id CAA14092; Tue, 8 Jun 1999 02:40:57 +0100 (BST) (envelope-from brian@keep.lan.Awfulhak.org) Message-Id: <199906080140.CAA14092@keep.lan.Awfulhak.org> X-Mailer: exmh version 2.0.2 2/24/98 To: "Eugene M. Kim" Cc: hackers@freebsd.org Subject: Re: Session leader releasing the ctty In-reply-to: Your message of "Mon, 07 Jun 1999 17:14:48 PDT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 08 Jun 1999 02:40:57 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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 Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message