Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141102162841.GP22465@brightrain.aerifal.cx>
Date: Sun, 2 Nov 2014 11:28:41 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Add login_tty

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.