public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] login_tty: Rewrite following FreeBSD's traces
@ 2016-11-24 11:06 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2016-11-24 11:06 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d3becf43185de8b54c3d6721d958b781f5e12fff
commit d3becf43185de8b54c3d6721d958b781f5e12fff
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Thu Nov 24 12:06:29 2016 +0100
login_tty: Rewrite following FreeBSD's traces
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/libc/bsdlib.cc | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc
index 89bc943..8e10827 100644
--- a/winsup/cygwin/libc/bsdlib.cc
+++ b/winsup/cygwin/libc/bsdlib.cc
@@ -77,22 +77,15 @@ daemon (int nochdir, int noclose)
extern "C" int
login_tty (int fd)
{
- char *fdname;
- int newfd;
-
- if (setsid () == -1)
+ /* If setsid fails, FreeBSD uses the current sid returned by getsid(0),
+ then calls tcsetsid, which we don't provide (just as Linux doesn't).
+ tcsetsid only uses the sid to check against the value returned by
+ getsid(0). So, either way, that check will not fail and we can
+ simply ignore the return value from setsid and just perform the
+ ioctl call tcsetsid does. */
+ setsid ();
+ if (ioctl (fd, TIOCSCTTY, NULL) == -1)
return -1;
- if ((fdname = ttyname (fd)))
- {
- if (fd != STDIN_FILENO)
- close (STDIN_FILENO);
- if (fd != STDOUT_FILENO)
- close (STDOUT_FILENO);
- if (fd != STDERR_FILENO)
- close (STDERR_FILENO);
- newfd = open (fdname, O_RDWR);
- close (newfd);
- }
dup2 (fd, STDIN_FILENO);
dup2 (fd, STDOUT_FILENO);
dup2 (fd, STDERR_FILENO);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-11-24 11:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24 11:06 [newlib-cygwin] login_tty: Rewrite following FreeBSD's traces Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).