output redirection from a compat
Jack Slingwine
jds at rlgvax.UUCP
Sun Jun 10 01:08:33 AEST 1984
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
More information about the Comp.unix.wizards
mailing list