wineconsole: Wait on events in curses backend using select instead of poll

Martin Storsjö martin at martin.st
Thu Dec 4 02:02:33 CST 2008


On Thu, 4 Dec 2008, Damjan Jovanovic wrote:

> On Mon, Dec 1, 2008 at 11:57 AM, Martin Storsjö <martin at martin.st> wrote:
>>
>> But there may of course be other reasons for using poll, which I don't know
>> about.
>
> select() not only has a hard limit on the number of file descriptors
> (1024 or whatever) that can only be increased at kernel and libc build
> time, but also has a corresponding limit on the maximum file
> descriptor that can be selected (1023).

Ah, thanks for pointing this out.

> On the other hand, console handles presumably exist on the low file
> descriptors (0, 1, and 2 - though doesn't transferring fds from the
> wineserver result in call to dup() which can change that?) and we poll
> very few of them, so those could possibly be done using select() - on
> MacOS *only*.

So, what would be the correct and clean way of conditionally enabling 
this?

The broken poll behaviour could be checked with this kind of snippet:

#include <poll.h>

int main(int argc, char** argv) {
         struct pollfd pfd;
         pfd.fd = 0;
         pfd.events = POLLIN;
         poll(&pfd, 1, 0);
         return (pfd.revents & POLLNVAL) ? 1 : 0;
}

Should this kind of detection be welded into configure in some way?

Or would it be better to simply define e.g. POLL_BROKEN whenever building 
for Darwin? That way, the binary would work well on all versions even if 
built on some newer version, if they would happen to fix the bug there.

Regards,
// Martin


More information about the wine-devel mailing list