I must be using this wrong on Windows. The code works on Unix, but seems to hang on Windows. A secondary problem is that the filehandles seem to get messed up, which I'm guessing is due to the way forking is emulated on Windows. Here's a snippet (strict/warnings/etc implied).

my $cv = AnyEvent::Util::run_cmd( [ $^X, -e => 'print "hello $^V\n"; exit 3' ], '>' => '/my.out', # for simplicity - somewhere that I have write ac +cess is being used '2>' => '/my.err', ); print "Started.\n"; # this goes to /my.out on windows, to the terminal + on unix my $rc = $cv->recv; # this hangs on windows, returns nearly instantly +on unix
I've tried with both 32-bit perl 5.10.0 (ActiveState) and 64-bit 5.22.1 (unknown source), and got the same results. (Windows 2008, but I doubt that matters.)

I started out with a reduced-functionality version of run_cmd, with an intention to eventually move to AE, but it had some similar problems, and I figured that the AE author may have worked around those problems already, so I started testing with AE instead, got stuck here. If AE doesn't work here, I may be forced to try to find a solution to my reduced-functionality version (which mostly was around the fork/filehandle issue - I'm sure I can resolve that, in a subprocess if I have to), but I'm figuring there has to be a simpler way, preferably one that will eventually allow me to read in both stdout and stderr without the temporary files.

Any suggestions would be appreciated.


In reply to AnyEvent::Util::run_cmd on Windows by Tanktalus

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.