Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!floyd!cmcl2!seismo!rlgvax!jds
From: jds@rlgvax.UUCP (Jack Slingwine)
Newsgroups: net.unix-wizards
Subject: Re: output redirection from a  compat
Message-ID: <2009@rlgvax.UUCP>
Date: Sat, 9-Jun-84 11:08:33 EDT
Article-I.D.: rlgvax.2009
Posted: Sat Jun  9 11:08:33 1984
Date-Received: Sun, 10-Jun-84 01:54:39 EDT
References: <972@linus.UUCP> <7422@umcp-cs.UUCP> <2001@rlgvax.UUCP>
Organization: CCI Office Systems Group, Reston, VA
Lines: 38

If you are running under 4.2BSD (or have the BBN or UNET networking
stuff under 4.1) you could solve the problem by using pseudo
ttys.  Redirect the standard output and error of chess (pdp11 emulation
program that is) into the slave device of the pseudo tty (/dev/ttyp?),
and have the "filter" read from the master device (/dev/ttyp?).  A more
general solution would be to write a program (called something original
like "x") which would do the necessary redirection and run the program.
The syntax would be:

	x [-*fileno* ...] pgm [args ...]

An outline of "x":

	main(...)
	{
		Allocate a pseudo tty;
		if (fork() == 0){
			open the slave device of the pseudo tty;
			redirect the necessary file descriptors to
				the slave device;
			set the tty modes of the pseudo tty slave
				to the tty modes of the standard input;
			exec "pgm" with "args";
		}

		open the master device of the pseudo tty;
		while (not eof on the master device){
			read from the master device;
			write to the standard output using whatever
				buffering you like;
		}
	}

Since the pseudo tty *is* a tty (as far as "isatty" is concerned),
standard I/O will be fooled into doing the right kind of buffering.

		Jack Slingwine
	{seismo,ihnp4,allegra}!rlgvax!jds