select() problems with pipes and ptys on ODT 1.0

Keith Moore moore at hydra1f.cs.utk.edu
Wed Feb 13 16:13:11 AEST 1991


This cropped up while I was trying to get GNU Emacs 18.57 running
under SCO's ODT 1.0.  I use both X and non-X environments, and would
like a single emacs to work under both.

If I compile the code for the non-X environment, without HAVE_SELECT
defined, and I try to run subprocesses under emacs, the response is
quite jerky as emacs emulates BSD select() by sleeping for a second
at a time between read attempts.  This works better with some devices
(probably those that support ioctl FIONREAD) than others.

If I define HAVE_SELECT and use the select() routine from the -lsocket
library, emacs loops continuously displaying "select error: invalid argument"
in the minibuffer.  This happens even if the only fd being waited on
is the terminal (in this case a pseudo-tty under an X window).

If I compile emacs with X windows support, the select() routine from
the socket library is required.  This works okay while emacs is taking
keyboard input from the X window, but breaks when I try to run a
subprocess with input from a pipe.  I worked around this by writing a
version of pipe() that builds a tcp connection to the local machine,
(since select() was obviously included for the purpose of porting BSD
networking code), but the resulting emacs still breaks when I run it
from a pseudo-tty or from the bare console.

I assume that this is because the library select() routine is implemented
in terms of the SYSV poll() syscall, and because neither pipes (as created
by pipe()) nor pseudo-ttys (the kind X uses, anyway) support STREAMS.

I am in the process of attempting to write a version of select() that
uses ioctl(FIONREAD) as well as poll() as well as any other tricks
I can think of to get it to work transparently without being too
inefficient.  

Questions:

1.  Can anyone verify my assumption that select() is broken because
    it uses poll(), or otherwise shed more light on this problem?
1.  Has anyone else built a better version of select() for SYSV
    boxes?
3.  I think there must be a streams pty that supports select().
    Is it possible to get Xsight's xterm to use streams ptys?
    What do I lose if I use streams ptys instead of BSD-style?
    (For instance, can I still do FIONREAD and set window size or am I
    stuck with pure termios-style ioctls?)
4.  Can anyone give me a pointer to a code example that builds a pipe
    using STREAMS?

--
Keith Moore / U.Tenn CS Dept / 107 Ayres Hall / Knoxville TN  37996-1301
Internet: moore at cs.utk.edu      BITNET: moore at utkvx



More information about the Comp.unix.sysv386 mailing list