in windows what would be the "normal" return code, 0 or 1?

0 for success, like unix.

then did echo %ERRORLEVEL% and the value returned was -1.

That's weird. Error codes are unsigned in Win32. IF ERRORLEVEL even relies on that.

@echo off program.exe if errorlevel 3 goto ERROR if errorlevel 1 goto WARNING rem 0 <= errorlevel < 1 echo Success goto END :WARNING rem 1 <= errorlevel < 3 echo Warning goto END :ERROR rem 3 <= errorlevel echo Error :END

That's a very strange error message to return in the event of a negative return code.

No, the message is correct for a negative code being returned from the function that implements system. The problem is that the function is returning negative when the child was successfully launched.

In Win32, exit codes are unsigned 32 bit values. Perl treats it as a signed 32-bit value.

DWORD status; ... GetExitCodeProcess(ProcessInformation.hProcess, &status); ret = (int)status;

The second line is a bug. Sufficiently high exit codes will be converted to negative. Negatives are used to signal a problem launching the process.


In reply to Re^3: Can't spawn "cmd.exe": by ikegami
in thread Can't spawn "cmd.exe": by emalossi

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.