Hi.

I've found out that ':' for stdin in an exec pattern doesn't
work. The reason is that if '!' is used for stdin, then the
w_pty fd is just duped to the sub process, so that the p_pty
is bypassed. But with ':' there is a relay mechanism via the
p_pty. In order to match the behaviour of the bypassed pty,
the pty must be set to raw mode, which is what the attached
patch does.
Without the attached patch, if the relayed data does not contain
the '\n's, the sub-process will simply receive nothing at all, because
the pty is then line-buffered.

Does the patch look good?
From 75c4ab457e2a992859e022ca7015229413ebe185 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Wed, 20 Mar 2013 20:17:06 +0400
Subject: [PATCH] exec: fix ':' for stdin.

Need to set TTY into raw mode to match the behaveur of the duped fd '!'
---
 src/window.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/window.c b/src/window.c
index f5e30a9..a00d757 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1392,6 +1392,13 @@ char **args, *ttyn;
 	      modep->m_ttyb.sg_flags &= ~ECHO;
 # endif
 	    }
+	  /* When stdin is ':' we need raw mode, so that it works similar
+	   * to '!', where the pty fd is duped.
+	   */
+	  if ((pat & F_PBOTH) == F_PBOTH)
+	    {
+	      cfmakeraw(&modep->tio);
+	    }
 #endif
 	  SetTTY(newfd, modep);
 #ifdef TIOCSWINSZ
-- 
1.7.11.7

_______________________________________________
screen-users mailing list
screen-users@gnu.org
https://lists.gnu.org/mailman/listinfo/screen-users

Reply via email to