From owner-freebsd-hackers Fri Nov 8 13:13:25 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA09050 for hackers-outgoing; Fri, 8 Nov 1996 13:13:25 -0800 (PST) Received: from delphi.bsd.uchicago.edu (delphi.bsd.uchicago.edu [128.135.5.5]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id NAA09040 for ; Fri, 8 Nov 1996 13:13:21 -0800 (PST) Received: from bio-5.bsd.uchicago.edu (bio-5.bsd.uchicago.edu [128.135.75.14]) by delphi.bsd.uchicago.edu (8.7.6/8.7.3/BSD-4.0) with SMTP id PAA25961; Fri, 8 Nov 1996 15:12:32 -0600 (CST) Received: by bio-5.bsd.uchicago.edu (5.0/SMI-SVR4) id AA11234; Fri, 8 Nov 1996 15:12:25 +0600 Date: Fri, 8 Nov 1996 15:12:25 +0600 Message-Id: <9611082112.AA11234@bio-5.bsd.uchicago.edu> To: bde@zeta.org.au Cc: hackers@FreeBSD.org In-Reply-To: <199611081551.CAA08229@godzilla.zeta.org.au> (message from Bruce Evans on Sat, 9 Nov 1996 02:51:00 +1100) Subject: Re: TIOCSPGRP on ptys? From: Tim Pierce Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Bruce Evans said: > [I wrote:] > > >In fact, the source for kern/tty_pty.c seems to > >be written to prevent *any* ioctls from being performed on slave > >ptys, and to prevent most TIOC ioctls from being performed on > >master ptys. Clearly I spoke too rashly. I did not notice that ptyioctl() calls ttioctl() for any unhandled ioctls -- only that it calls the line discipline ioctl after checking special cases first. My bad. > In BSD4.4Lite, there is essentially only > one working method: > > 1. Stop being a process group leader, e.g., by forking and continuing > in the child. This is necessary for step 2 to work. See setsid(2). > 2. Open the new tty. > 3. Call setsid() to become a session leader. > 4. Call ioctl(fd, TIOCSCTTY) to get a controlling terminal. > 5. Call tcsetpgrp(fd, groupid) or an ioctl to set the process group. > > login_tty() does steps (3) and (4) plus some simple plumbing. It is > documented in lgin_tty.c :-). These interfaces have been stable for > 4+ years. Thanks for the elucidation. I was not sure whether login_tty() is the preferred mechanism because I could find no documentation for it and did not know how long it has been a part of 4BSD. Should a man3 page be included for it? (I could contribute one if it is agreed that this is a good idea.)