From xemacs-m  Tue May 20 18:35:47 1997
Received: from CNRI.Reston.VA.US (CNRI.Reston.VA.US [132.151.1.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id SAA15836
	for <xemacs-beta@xemacs.org>; Tue, 20 May 1997 18:35:47 -0500 (CDT)
Received: from newcnri.cnri.reston.va.us by CNRI.Reston.VA.US id aa17430;
          20 May 97 19:34 EDT
Received: from anthem.CNRI.Reston.Va.US by newcnri.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id TAA03775; Tue, 20 May 1997 19:34:26 -0400
Received: by anthem.CNRI.Reston.Va.US (SMI-8.6/SMI-SVR4)
	id TAA15002; Tue, 20 May 1997 19:34:02 -0400
Date: Tue, 20 May 1997 19:34:02 -0400
Message-Id: <199705202334.TAA15002@anthem.CNRI.Reston.Va.US>
From: "Barry A. Warsaw" <bwarsaw@CNRI.Reston.VA.US>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: davidh@wr.com.au
Cc: xemacs-beta@xemacs.org
Subject: Re: select problems in the (almost) NT port
References: <9705201245.AA01037@wr.com.au>
X-Mailer: VM 6.30 under 19.15p4 XEmacs Lucid
Reply-To: bwarsaw@python.org
X-Attribution: BAW
X-Oblique-Strategy: Short circuit
X-Url: http://www.python.org/~bwarsaw


>>>>> "DH" == David Hobley <davidh@wr.com.au> writes:

    DH> I have run into a bit of a stumbling block with the NT
    DH> port. XEmacs assumes that adding plain file descriptors with
    DH> XtAppAddInput() is going to work.

    DH> Unfortunately, under Windows, select only works with sockets,
    DH> not files and as such the XtAppMainLoop fails as soon as
    DH> select gets called (deep in the internals).

    DH> I could try and rewrite select, but the more I think about it,
    DH> the more of a kludge that feels like.

    DH> Could someone explain to me the reason XEmacs wants to add
    DH> (plain) file descriptors via XtAppAddInput() ? Surely they
    DH> would always return true. Would it be better to abstract that
    DH> out, or should I bite the bullet and rewrite select (somehow
    DH> ;-) ?

    DH> The GNU Emacs port has a rewritten select to allow for
    DH> subprocesses, I may be forced to go along that route anyway,
    DH> but I would prefer not to.

I talked to Guido van Rossum about this today.  I mention this because
we had a similar problem when porting Grail to NT (Guido is Python's
inventor).  He said that for the NT port he basically turned of
caching, which has the effect of never adding plain file descriptors
to the underlying select call.  He says, it just doesn't work, so
don't do it.  He also says that you don't every really need to do this
since the files will always be ready, even when you're at EOF.  The
problem, he says, is that if you just have the integer fd, you can't
tell whether its for a file or socket, so you basically have to keep
track of that information.

We talked about a couple of approaches Python/Grail might take.  The
most viable seems to be to wrap the the fd in an object (struct) that
has another field saying whether it's a plain file or not.  So you'd
check that struct field before calling XtAppAddInput.  I don't know
whether any of this helps, or how much work it would be to do this,
but I wish you lots of luck (I'd love to see a native NT port).

-Barry

