Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Unaltered child return code on Windows

by salva (Abbot)
on Dec 16, 2014 at 16:48 UTC ( #1110517=perlquestion: print w/replies, xml ) Need Help??
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 (Pope) 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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1110517]
Front-paged by toolic
help
Chatterbox?
[LanX]: yes
[hippo]: Why not just try and see?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2018-07-23 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (469 votes). Check out past polls.

    Notices?