I've tried to trace this through, but I haven't found a work-around. It appears to be hanging at this Win32_msgwait() (win32.c:3976):

else { DWORD status; win32_msgwait(aTHX_ 1, &ProcessInformation.hProcess, INFINITE, + NULL); /* FIXME: if msgwait returned due to message perhaps forward t +he "signal" to the process */ GetExitCodeProcess(ProcessInformation.hProcess, &status); ret = (int)status; CloseHandle(ProcessInformation.hProcess); }

The first parameter in that call (1), is meant to indicate the number of handles that should be waited for, but this code was probably written before the advent of threading, hence the constant. I think what is happening is that in a multi-threaded app that spawns concurrent child processes on different threads, the number of process handles eligable can be more than one, and under some circumstances, the one that should be waited upon is not the first one. Hence it deadlocks. I think.

The whole treatment of how the unix concept of wait & waitpid are emulated under Win32 relies on some fairly dubious coding from what I can see and I am unable to see a simple work-around to allow it to work properly in a multi-threaded environment. I've given a little thought on how it might be restructures, but making it work mutli-threaded without screwing up or imposing undue overhead for single threaded Perl woudl require a deeper understanding of the Unix concepts than I have.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^11: Behavior of threads on XP-- system() works, backtic & popen don't... by BrowserUk
in thread Behavior of threads on XP-- system() works, backtic & popen don't... by Sync

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.