Detecting Pipe Using Bourne Shell

Kristoffer Eriksson ske at pkmab.se
Fri Apr 14 09:11:38 AEST 1989


In article <457 at cbnewsc.ATT.COM>, nichols at cbnewsc.ATT.COM (robert.k.nichols) writes:
> In article <999 at philmds.UUCP> leo at philmds.UUCP (Leo de Wit) writes:
> Programs and procedures that use this means of distinguishing their
> input source are one of my pet peeves.  Sometimes I want to interpose an
> editing filter between my terminal and stdin of some program, giving me
> the ability to repeat previous input lines (perhaps with modifications),
> include the contents of an existing file in the input stream, etc.  Any
> program that uses "test -t 0" (or an equivalent) will break in such an
> environment.

I would like too see this problem with piping into (out of) programs that
want to use ioctl calls on its input (output) permanently cured some day.

I think the cure would be to make it possible for ioctl:s to be transferred
throu the pipe (or actually more likely, throu some parallell but unbuffered
mechanism), and read by the process at the other end of the pipe with a new
system call that could be named ioctlread(). That process then could emulate
the requested ioctl or pass it on to some other file or pipe. This would be
perfectly suited for editing filters, windowing systems, networked terminal
sessions, and more, without using ptys or System V stream modules.

Ptys are not equivelent to these extended pipes (let's call them "e-pipes").
With e-pipes, all ioctls can be passed throu the filter process or processes
all the way to the actual devices they filter, thus not limiting them to
handle tty style devices only, with only the ioctls implemented by the pty
driver (better generality). You also could have tty modes on remotely logged
in terminals in a network, propagate (with some suitable protocol) from the
remote host to the terminals local host's tty driver (or editing filter),
to do all input processing near the terminal (increased efficiency), all
without any special kernel drivers.

To further increase the usefulness of e-pipes, eliminating the need for
filter programs to know anything about e-pipes, there could be a default
"by-pass" setup where ioctls coming in on stdin automatically were passed
on to stdout, and vice versa, until the process explicitly requests to
receive the ioctls itself. This would only involve checking and optionally
following a "by-pass pointer" in the kernel, when sending ioctls. Maybe
the shell that started the pipe could arrange the by-pass according to how
the pipe was specified, using a new bypass() or shunt() system call.

With this facility it would be possible to e.g. use good old tr in a
pipe between your terminal and any other program, like editors, mail
readers, pagers, anything, without trouble. Today you can't.

I don't know enough to compare e-pipes to stream modules, but from what I've
seen on the net, they seem to be designed mostly for use from within the
kernel, and complicated to set up for use with user processes. Maybe the
shell could be made to set up streams similar to e-pipes, but I think there
would be problems/limitations.

What do you say? I want pipes usable with modern, interactive, screen
oriented, modular programs, in addition to the usual old text processing.
-- 
Kristoffer Eriksson, Peridot Konsult AB, Hagagatan 6, S-703 40 Oerebro, Sweden
Phone: +46 19-13 03 60  !  e-mail: ske at pkmab.se
Fax:   +46 19-11 51 03  !  or ...!{uunet,mcvax}!sunic.sunet.se!kullmar!pkmab!ske



More information about the Comp.unix.wizards mailing list