|
|
Message-ID: <20140904212159.GG10361@port70.net>
Date: Thu, 4 Sep 2014 23:22:00 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: Add login_tty
* Felix Janda <felix.janda@...teo.de> [2014-08-26 18:56:28 +0200]:
> --- /dev/null
> +++ b/src/misc/login_tty.c
> @@ -0,0 +1,14 @@
> +#include <utmp.h>
> +#include <sys/ioctl.h>
> +#include <unistd.h>
> +
> +int login_tty(int fd)
> +{
> + setsid();
> + if (ioctl(fd, TIOCSCTTY, (char *)0)) return -1;
> + dup2(fd, 0);
> + dup2(fd, 1);
> + dup2(fd, 2);
> + if (fd>2) close(fd);
> + return 0;
> +}
i recently came across this:
http://lxr.free-electrons.com/source/fs/file.c#L751
so dup2 may spuriously fail with EBUSY on linux
the current forkpty does not check dup2 either, but i
wonder if it should be
while(dup2(fd,0)==-1 && errno==EBUSY);
instead
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.