Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Unaltered child return code on Windows

by salva (Canon)
on Dec 16, 2014 at 16:48 UTC ( [id://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 (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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1110517]
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-19 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found