[comp.sys.encore] TIOCSTI and the call protocol dont mix

loverso@Xylogics.COM (John Robert LoVerso) (07/04/89)

In article <8907040132.927@munnari.oz.au> ejd@goanna.oz.AU (Erick Delios) writes:
> There is a problem with the interaction between the Call protocol and 
> TIOCSTI.  The problems occurs here with the 4.3BSD tahoe csh that
> I have just put on the 310. The problem is that the input line generated by
> TIOCSTI is not output to the terminal until the user types a character 
> at the keyboard (or manually does a ^R). 

This is not a problem with the TIOCSTIs done to stuff the characters,
but rather a bug with LPENDIN bit set to have the input buffer
displayed when "the next read occurs".  The problem is that RDP
(the protocol implementing "call" and "rnodes") doesn't provide
for a way for the host process to signal it's "waiting for input"
(without generating excess network traffic; the problem wasn't ever
regarded highly enough to get fixed).

Two years ago (or so) I posted these diffs to fix the problem.  Basiclly,
instead of using LPENDIN, just don't turn off ECHO as the characters are
TIOCSTId.  It works, but not nicely.  (I just don't use "call" for login
sessions, so this never bothers me).  Anyway, just apply these diffs and
compile using "-DBROKEN_LPENDIN".

I know that the 4BSD-based UMAX (UMAX4.2) has a 4.3 csh that works correctly
in this regard.  I'm surprised that the UMAXV csh doesn't do this correctly.

-- 
John Robert LoVerso			Xylogics, Inc.  617/272-8140
loverso@Xylogics.COM			Annex Terminal Server Development Group
encore!xylogics!loverso			[formerly of Encore Computer Corp]


*** /source/BSD4.3/src/bin/csh/sh.file.c	Mon May 19 02:01:20 1986
--- ./sh.file.c	Mon Oct 19 16:59:43 1987
***************
*** 89,95 ****
--- 89,100 ----
   * Push string contents back into tty queue
   */
  static
+ #ifndef BROKEN_LPENDIN
  pushback(string)
+ #else
+ pushback(string, displayit)
+ 	char displayit;
+ #endif
  	char *string;
  {
  	register char *p;
***************
*** 97,109 ****
--- 102,123 ----
  	int omask;
  
  	omask = sigblock(sigmask(SIGINT));
+ #ifdef BROKEN_LPENDIN
+ 	if (displayit == FALSE) {
+ #endif
  	(void) ioctl(SHOUT, TIOCGETP, (char *)&tty);
  	tty_normal = tty;
  	tty.sg_flags &= ~ECHO;
  	(void) ioctl(SHOUT, TIOCSETN, (char *)&tty);
+ #ifdef BROKEN_LPENDIN
+ 	}
+ #endif
  
  	for (p = string; *p; p++)
  		(void) ioctl(SHOUT, TIOCSTI, p);
+ #ifdef BROKEN_LPENDIN
+ 	if (displayit == FALSE)
+ #endif
  	(void) ioctl(SHOUT, TIOCSETN, (char *)&tty_normal);
  	(void) sigsetmask(omask);
  }
***************
*** 251,259 ****
--- 265,275 ----
  static
  retype()
  {
+ #ifndef BROKEN_LPENDIN
  	int pending_input = LPENDIN;
  
  	(void) ioctl(SHOUT, TIOCLBIS, (char *)&pending_input);
+ #endif
  }
  
  static
***************
*** 571,579 ****
--- 587,599 ----
  			should_retype = TRUE;
  		if (should_retype)
  			printprompt();
+ #ifndef BROKEN_LPENDIN
  		pushback(inputline);
  		if (should_retype)
  			retype();
+ #else
+ 		pushback(inputline, should_retype);
+ #endif
  	}
  	setup_tty(OFF);
  	return (num_read);

ejd@goanna.oz.AU (Erick Delios) (07/04/89)

There is a problem with the interaction between the Call protocol and 
TIOCSTI.  The problems occurs here with the 4.3BSD tahoe csh that
I have just put on the 310. The problem is that the input line generated by
TIOCSTI is not output to the terminal until the user types a character 
at the keyboard (or manually does a ^R). 

Repeat by:	First compile the bsd4.3 tahoe csh 
		There is a kernel bug in the handling of dup2 and dup.
		follow each occurrence of either of these in the file sh.misc.c
		with "(void) ioctl(k, FIONCLEX, (char *)0);"
		Run the shell and try the following:

		% set filec
		% ls /bin/d<CTRL D> 
		date	df	dis
		dd	diff	du
		% 

This behaviour also occurs on the /bin/csh that is supplied with Umax 2.2f. 
Does anyone know what the problem is and how to work around it.

Thanks,

Erick Delios

ACSnet: ejd@goanna.cs.rmit.oz     UUCP: ...!uunet!munnari!goanna.cs.rmit.oz!ejd
CSNET:	ejd@goanna.cs.rmit.oz     ARPA: ejd%goanna.cs.rmit.oz@uunet.uu.net
BITNET:	ejd%goanna.cs.rmit.oz@CSNET-RELAY    PHONE:  + 61 3 660 2291

Department of Computer Science,
Royal Melbourne Institute of Technology,
P.O. Box 2476V,
124 Latrobe St,
Melbourne, 3000, Australia
------