dk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I believe many of you have banged your head against the wall when you discovered that win32 pipes and file handles don't work together with select() -- only sockets do. Me too. Now, I was thinking, I could fork off a thread, that would listen on a f.ex udp port, would repeatedly call WaitForMultipleObjects (or Win32::IPC::wait_for_any, if that works), and send a dummy packed to the socket whenever that win32 call reports that some async event occured. That scheme would enable the main thread to use select(), of course with some wrappings, but still, it would be a full-weight select, that would work with pipes, handles, and any other win32 async machinery such as mutexes, semaphores, processes etc etc.

Now I have a question. My alpha prototype shows that the concept works. I am unsure however if I'm reinventing the wheel, mainly because the problem is very old, and I doubt that no one ever approached it. The solutions I've seen are partial, like IPC::Run that works for async execution only. Of course there's cygwin where select() just works. So my question is, do you know a module, or a common technique that solves this problem? Or, possibly you know that the problem (or expected solution) covers more than just pipes/filehandles/win32 objects?

Thank you!

ps. Usually people ask why. Here's why: event loop modules don't seem to work with non-blocking open("-|"). Basically, now I want a non-blocking version of system(), but possibly I'll also need the same for IPC::Open2 .

Replies are listed 'Best First'.
Re: win32 and select
by zentara (Cardinal) on Aug 17, 2008 at 12:12 UTC
    Shouldn't Microsoft be responsible for fixing this down in their c code? (I blame Microsoft for everything wrong in computing :-) )

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      I don't think they consider it broken, its just not part of their design spec
        Look! Up in the sky.....it's a bug... it's a feature.....no....it's the crud on the Windows.:-)

        I'm not really a human, but I play one on earth Remember How Lucky You Are
Re: win32 and select
by BrowserUk (Patriarch) on Aug 16, 2008 at 23:11 UTC
      xp whoring--

        Anonymous cowardice-- Worrying about other people's XP--

        Believing that my reasons for posting anything, is the oh so valuable accumulation of XP of which I already have an abundance: a sad reflection of your motivations. Not mine.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
      If you rig'em right, you can drive from the roof. You can even have your own comic , the Adventures of ApeBack :D

        The roof? Nah! The back seat. You gotta get that laid-back style.

        The handbar controls'd take care of most of the logistics. I forsee only two problems:

        1. It'll look weird with the wing mirrors mounted on the back doors.
        2. Operating a 5-speed H-pattern shift gate with my left foot is going to take some getting used to.

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.