dk has asked for the wisdom of the Perl Monks concerning the following question:
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 | |
by Anonymous Monk on Aug 17, 2008 at 18:46 UTC | |
by zentara (Cardinal) on Aug 18, 2008 at 13:56 UTC | |
|
Re: win32 and select
by BrowserUk (Patriarch) on Aug 16, 2008 at 23:11 UTC | |
by Anonymous Monk on Aug 17, 2008 at 10:14 UTC | |
by BrowserUk (Patriarch) on Aug 18, 2008 at 04:58 UTC | |
by Anonymous Monk on Aug 17, 2008 at 03:23 UTC | |
by BrowserUk (Patriarch) on Aug 17, 2008 at 04:09 UTC | |
by Gavin (Archbishop) on Aug 17, 2008 at 10:18 UTC |