summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/fhandler_console.cc4
-rw-r--r--winsup/cygwin/fhandler_termios.cc4
-rw-r--r--winsup/cygwin/fhandler_tty.cc11
4 files changed, 26 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 53a003a95..7c87e672a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+2012-03-03 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * fhandler_console.cc (fhandler_console::dup): Only set ctty when we
+ haven't specifically called setsid.
+ * fhandler_tty.cc (fhandler_pty_slave::dup): Ditto. Also add comment
+ documenting research into rxvt problem.
+ * fhandler_termios.cc (fhandler_termios::tcsetpgrp): Don't check
+ specifically for myself->ctty == -1. Test for > 0 as that is the
+ correct test.
+ (fhandler_termios::sigflush): Ditto.
+
2012-03-02 Corinna Vinschen <corinna@vinschen.de>
* flock.cc (allow_others_to_sync): Reorder conditional expression to
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 4ed56635f..a30b717d2 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -759,7 +759,9 @@ fhandler_console::scroll_screen (int x1, int y1, int x2, int y2, int xn, int yn)
int
fhandler_console::dup (fhandler_base *child, int flags)
{
- myself->set_ctty (this, flags);
+ /* See comments in fhandler_pty_slave::dup */
+ if (myself->ctty != -2)
+ myself->set_ctty (this, flags);
return 0;
}
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index 36017dc63..70fb12877 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -99,7 +99,7 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
int
fhandler_termios::tcgetpgrp ()
{
- if (myself->ctty != -1 && myself->ctty == tc ()->ntty)
+ if (myself->ctty > 0 && myself->ctty == tc ()->ntty)
return tc ()->pgid;
set_errno (ENOTTY);
return -1;
@@ -404,7 +404,7 @@ fhandler_termios::sigflush ()
pid_t
fhandler_termios::tcgetsid ()
{
- if (myself->ctty != -1 && myself->ctty == tc ()->ntty)
+ if (myself->ctty > 0 && myself->ctty == tc ()->ntty)
return tc ()->getsid ();
set_errno (ENOTTY);
return -1;
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index b316a0aaf..547cf72b8 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -898,7 +898,16 @@ out:
int
fhandler_pty_slave::dup (fhandler_base *child, int flags)
{
- myself->set_ctty (this, flags);
+ /* This code was added in Oct 2001 for some undisclosed reason.
+ However, setting the controlling tty on a dup causes rxvt to
+ hang when the parent does a dup since the controlling pgid changes.
+ Specifically testing for -2 (ctty has been setsid'ed) works around
+ this problem. However, it's difficult to see scenarios in which you
+ have a dup'able fd, no controlling tty, and not having run setsid.
+ So, we might want to consider getting rid of the set_ctty in tty-like dup
+ methods entirely at some point */
+ if (myself->ctty != -2)
+ myself->set_ctty (this, flags);
report_tty_counts (child, "duped slave", "");
return 0;
}