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 .


In reply to win32 and select by dk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.