'The only way a write pipe can become "readable" is at EOF, because the
child has closed it, and we\'re using a reactor which doesn\'t
distinguish between readable and closed (such as the select reactor).
Except that\'s not true on linux < 2.6.11. It has the following
characteristics: write pipe is completely empty => POLLOUT (writable in
select), write pipe is not completely empty => POLLIN (readable in
select), write pipe\'s reader closed => POLLIN|POLLERR (readable and
writable in select)
That\'s what this funky code is for. If linux was not broken, this
function could be simply "return CONNECTION_LOST".
BUG: We call select no matter what the reactor.
If the reactor is pollreactor, and the fd is > 1024, this will fail.
(only occurs on broken versions of linux, though).'

def doRead(self):

    if self.enableReadHack:
        if brokenLinuxPipeBehavior:
            fd = self.fd
            (r, w, x) = select.select([fd], [fd], [], 0)
            if (r and w):
                return CONNECTION_LOST
        else:
            return CONNECTION_LOST
    else:
        self.stopReading()
