[lldb-dev] select() on Windows

Zachary Turner zturner at google.com
Thu Jul 17 18:37:51 PDT 2014


So I've run into a potentially difficult issue on Windows.

I have the test suite actually running.  A few tests even passed
surprisingly.  But what doesn't work is one-shot script commands.  e.g. the
following:

(lldb) script print "foo"

Running this deadlocks.  The reason is related to the
ConnectionFileDescriptor class.  Basically, on Windows the select() API
will only accept sockets, nothing else.  It seems select() is only used
from the BytesAvailable() function, but that it attempts to simultaneously
check if data is available on a) the read file descriptor, which could be
an arbitrary object (pipe, socket, file, etc), and b) optionally, a pipe.

Is this correct?  There isn't a great equivalent for this on Windows.

It's possible to make it work, but at a minimum it's going to involve
re-implementing Pipe in terms of HANDLEs on Windows, because it's the only
way you can do non-blocking I/O on a Pipe.

For starters, we could just stub out an entirely separate implementation of
the function on Windows that makes use of this new HANDLE-based Pipe class,
but I imagine that's going to get old pretty fast if we need to use
select() in other places.  I did search the code and only saw select() used
in one other place, but perhaps at some point we'll need to abstract this
out into an actual platform-specific version of select.  FWIW Windows does
provide a rough equivalent, it just uses an entirely different API, and is
completely HANDLE-based, so this approach will probably require some more
work to make other types of objects (files, sockets, processes, etc)
HANDLE-based instead of fd-based on Windows.

Thoughts?  Suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140717/706f5da4/attachment.html>


More information about the lldb-dev mailing list