First, Windows can't fork processes. It spawns new processes.

The problem is that your error checking is buggy. You're reporting an error when none occurred.

system($file1); if ($? == -1) { die("Can't execute command: $!\n"); } elsif ($? & 127) { die("Command died from signal ", ($? & 127), "\n"); } elsif ($? >> 8) { die("Command exited with error ", ($? >> 8), "\n"); }

Update: While it's true that your error handling is buggy, it's not the cause of your problem. Could you please add the following lines after system (in either in your version or mine) and post the output.

use Devel::Peek; Dump($?);

I have a hard time believeing $? has a non-integer value or an integer value less than -1, but that's the only way you could get the results you report. This command will report quite precisely the value of $?.


In reply to Re: How to get output from a forked cmd prompt? by ikegami
in thread How to get output from a spawned cmd prompt? by Xhings

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.