salva has asked for the wisdom of the Perl Monks concerning the following question:

I am wrapping an external executable on Windows that can exit with codes bigger than 255. The issue I am facing is that Perl $? seems to be limited to the combination of one byte for the signal and another byte for the errorlevel. For instance, when the program exits with code 1000 (0x3E8), $? becomes 59392 (0xE800).

Perl has also the variable ${^CHILD_ERROR_NATIVE}, but it seems that on Windows it gets the same value as $?.

Does anybody known how to get the real exit code without reverting to using an external module as Win32::Process to start and control the slave processes? (on the other hand, I am already using Win32::API, so solutions using it would be acceptable).

Replies are listed 'Best First'.
Re: Unaltered child return code on Windows
by BrowserUk (Patriarch) on Dec 16, 2014 at 17:13 UTC

    You can use OpenProcess() to get a handle to the process from its pid. And then use GetProcessExitCode() to get the return value from the handle.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      That works, thank you!