From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6426 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Add login_tty Date: Sun, 2 Nov 2014 11:28:41 -0500 Message-ID: <20141102162841.GP22465@brightrain.aerifal.cx> References: <20140825224333.GX12888@brightrain.aerifal.cx> <20140826165627.GA1208@euler> <20141031161907.GD22465@brightrain.aerifal.cx> <20141101211523.GA13145@euler> <20141101214503.GK22465@brightrain.aerifal.cx> <20141101222729.GB5949@euler> <20141101224325.GM22465@brightrain.aerifal.cx> <20141101225643.GA8817@euler> <20141102000944.GN22465@brightrain.aerifal.cx> <20141102141912.GA3637@euler> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1414945747 29471 80.91.229.3 (2 Nov 2014 16:29:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Nov 2014 16:29:07 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6439-gllmg-musl=m.gmane.org@lists.openwall.com Sun Nov 02 17:29:00 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Xky1R-00015n-Bj for gllmg-musl@m.gmane.org; Sun, 02 Nov 2014 17:28:57 +0100 Original-Received: (qmail 9525 invoked by uid 550); 2 Nov 2014 16:28:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9517 invoked from network); 2 Nov 2014 16:28:55 -0000 Content-Disposition: inline In-Reply-To: <20141102141912.GA3637@euler> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6426 Archived-At: On Sun, Nov 02, 2014 at 03:19:12PM +0100, Felix Janda wrote: > > > int login_tty(int fd) > > > { > > > int ret; > > > setsid(); > > > ret = ioctl(fd, TIOCSCTTY, (char *)0); > > > dup2(fd, 0); > > > dup2(fd, 1); > > > dup2(fd, 2); > > > if (fd>2) close(fd); > > > return ret; > > > } > > > > This behavior seems preferable in itself, but it's inconsistent with > > what glibc and probably the BSDs do, so it's probably not a good idea. > > glibc's behavior seems to match your previous version. This is leading > > me to think maybe the code in forkpty should just stay separate. Do > > you have other ideas? > > I've checked that Free- Net- and OpenBSD have the behavior of the > previous version. > > Another approach would be to _exit in the child if login_tty fails. > However the parent might interpret the exit code. There's an approach I use in posix_spawn that could be copied here. My hope was to keep forkpty simpler but it's not too bad and it would make it so we could handle other arbitrary errors in the child if we ever need to, so maybe it's a good idea. Rich