summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Wang <dearvoid@gmail.com>2017-07-01 21:32:43 +0200
committerAmadeusz Sławiński <amade@asmblr.net>2017-07-01 21:32:43 +0200
commit0f5e9affa4c6d8cedd8b97a7f5436413ed124136 (patch)
treec01afe8eea697d7dcd6a79299770b9c8f4e9135c
parentf8fb068b510a6a5cf7fd374cbc91bd5635eb8f33 (diff)
downloadscreen-0f5e9affa4c6d8cedd8b97a7f5436413ed124136.tar.gz
restore missing code which was wrongly removed
fixes regression introduced by migrating from pipe to sockets http://lists.gnu.org/archive/html/screen-users/2017-06/msg00001.html
-rw-r--r--src/screen.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/screen.c b/src/screen.c
index 7dc6034..c3417e3 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -999,6 +999,7 @@ int main(int ac, char** av)
attach_tty = "";
if (!detached && !lsflag && !cmdflag && !(dflag && !mflag && !rflag && !xflag) &&
!(sty && !SockMatch && !mflag && !rflag && !xflag)) {
+ int fl;
/* ttyname implies isatty */
SetTtyname(true, &st);
@@ -1006,6 +1007,11 @@ int main(int ac, char** av)
tty_mode = (int)st.st_mode & 0777;
#endif
+ fl = fcntl(0, F_GETFL, 0);
+ if (fl != -1 && (fl & (O_RDWR|O_RDONLY|O_WRONLY)) == O_RDWR)
+ attach_fd = 0;
+
+
if (attach_fd == -1) {
if ((n = secopen(attach_tty, O_RDWR | O_NONBLOCK, 0)) < 0)
Panic(0, "Cannot open your terminal '%s' - please check.", attach_tty);