[comp.emacs] Streams, pseudo-tty's for UTS 5.2.5

djs@cblpe.ATT.COM (Doug Scofea) (06/04/87)

Hi netlanders.  I've been using GNU emacs 18.41.  It has a very nice mode
called shell.  In this mode, emacs starts a shell as a subprocess.  Input
to the shell (and the commands it starts) comes from an emacs buffer.  Output
from the shell as well as commands that don't have there output redirected
ends up in your buffer.  This is nice since it allows you to use the editor
to edit all input to all commands.  The problem is that emacs talks to the
shell using pipes.  This causes all commands that use standard I/O to have
buffered output unless the command specifically unbuffers output.  This makes
interactive commands pretty much useless.  Also, any command that tries to
do an ioctl will fail and the command gives up with a message such as
"Not a tty".

Under BSD, emacs can be compiled to use sockets which, I believe, overcome
these problems (Tell me if this is so, I have little knowledge of sockets
or streams).  We have recently upgraded our Amdahl to UTS 5.2.5 which seems
to have support for streams and remote file system.  The streams primer
seems to indicate its possible to write a stream module to implement
a pseudo-tty that can let all commands started by emacs appear to be connected
to a real tty but, have there output sent to emacs.

My knowledge is next to nothing on streams.  How does one determine what
streams modules there system has?  Are streams modules linked into the kernel?
If this is true, do they also appear in the file system as device drivers do?
Have there been any pseudo-tty streams modules written?  Would it be possible
to do what I want?  Would it be straightforward to convert the emacs code
that makes the socket calls to use streams?

Any help appreciated.
-- 
Doug Scofea  -  djs@cblpe.ATT.COM      Phone: +1 614 860 2065
UUCP:   ...!{akgua,gatech,ihnp4,ulysses}!cbosgd!cblpe!djs  

djs@cblpe.UUCP (06/06/87)

[This may be a repeat, our news feed is flakey and I don't think it got out]

Hi netlanders.  I've been using GNU emacs 18.41.  It has a very nice mode
called shell.  In this mode, emacs starts a shell as a subprocess.  Input
to the shell (and the commands it starts) comes from an emacs buffer.  Output
from the shell as well as commands that don't have there output redirected
ends up in your buffer.  This is nice since it allows you to use the editor
to edit all input to all commands.  The problem is that emacs talks to the
shell using pipes.  This causes all commands that use standard I/O to have
buffered output unless the command specifically unbuffers output.  This makes
interactive commands pretty much useless.  Also, any command that tries to
do an ioctl will fail and the command gives up with a message such as
"Not a tty".

Under BSD, emacs can be compiled to use sockets which, I believe, overcome
these problems (Tell me if this is so, I have little knowledge of sockets
or streams).  We have recently upgraded our Amdahl to UTS 5.2.5 which seems
to have support for streams and remote file system.  The streams primer
seems to indicate its possible to write a stream module to implement
a pseudo-tty that can let all commands started by emacs appear to be connected
to a real tty but, have there output sent to emacs.

My knowledge is next to nothing on streams.  How does one determine what
streams modules there system has?  Are streams modules linked into the kernel?
If this is true, do they also appear in the file system as device drivers do?
Have there been any pseudo-tty streams modules written?  Would it be possible
to do what I want?  Would it be straightforward to convert the emacs code
that makes the socket calls to use streams?

Any help appreciated.
-- 
Doug Scofea  -  djs@cblpe.ATT.COM      Phone: +1 614 860 2065
UUCP:   ...!{akgua,gatech,ihnp4,ulysses}!cbosgd!cblpe!djs  

guy%gorodish@Sun.COM (Guy Harris) (06/09/87)

> Under BSD, emacs can be compiled to use sockets which, I believe, overcome
> these problems (Tell me if this is so, I have little knowledge of sockets
> or streams).

I presume you mean pseudo-ttys rather than sockets, since you refer
to pseudo-ttys elsewhere.  Sockets wouldn't help here; they don't act
like ttys.  (Under 4.[23]BSD, in fact, pipes are implemented on top
of sockets)

> We have recently upgraded our Amdahl to UTS 5.2.5 which seems
> to have support for streams and remote file system.  The streams primer
> seems to indicate its possible to write a stream module to implement
> a pseudo-tty that can let all commands started by emacs appear to be
> connected to a real tty but, have there output sent to emacs.
> 
> My knowledge is next to nothing on streams.  How does one determine what
> streams modules there system has?

It depends on your system.  If the 3B2's boot-time configuration
scheme is used, there's probably a text file somewhere on the system
that indicates this.  If the streams modules are built in at link
time, then there may be a source file that is compiled into the
streams module table.  If you just get a kernel executable image,
there is a table that you can probably find with enough playing with
"/dev/kmem".

However, the best way would probably be to ask your vendor or check
the documentation; if they don't list what streams modules they
provide, they goofed.

Also note that there is a difference between streams modules (which
are sort of like line disciplines) and streams device drivers.  The
latter appear in the character device switch just as other character
device drivers do.  The pseudo-tty would have to be a driver, not a
streams module.

> Are streams modules linked into the kernel?

Yes.

> If this is true, do they also appear in the file system as device drivers
> do?

Streams devices do, since they are devices just like other character
devices.  Streams modules do not.

> Have there been any pseudo-tty streams modules written?

Yes, but I don't know whether they're available on your machine.

> Would it be possible to do what I want?

Maybe.  The trouble is that a pseudo-tty driver wouldn't be
sufficient; the tty subsystem has to be reimplemented to use streams
(AT&T has not released any such reimplemented subsystem, unless you
count V8 which was only released to a few universities).  A "streams
pipe" driver, which is supplied with S5R3, might either serve as a
pseudo-tty driver or be able to do so with a few changes; however,
you'd have to push a "generic tty driver" streams module on top of
it, and unless your system has that module you're out of luck.

The streams primer may be saying "given the streams framework, you
could implement a pseudo-tty device and streams modules to do generic
tty driver processing"; in the current situation, this amounts to "if
we had some ham, we could have ham and eggs, if we had some eggs".
It doesn't mean that the code delivered with S5R3 (I presume the UTS
version you are referring to is based on S5R3) includes those
modules.

> Would it be straightforward to convert the emacs code
> that makes the socket calls to use streams?

Again, presuming you meant "pseudo-tty" instead of "socket", it would
probably be straightforward; setting up the pseudo-tty would be done
somewhat differently, but reading and writing from the "controller"
side would be done pretty much the same.
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com