Is it possible to process exit codes> 255 with perl?

First, find a little background about the exit code in perl ( also here ) and on Windows .

Now - when I execute another process from a perl script (I am open with respect to the method, qx / open / system / exec / IPC::Run , etc.) on Windows :

can I lock exit codes outside the range 0 - 255 ?

On Windows, a process can return a full (signed) 32-bit exit code, and it's not uncommon to encounter something return 0x8...0... , that is, some COM error code or something like that.

+4
source share
2 answers

Yes, Win32 :: Process can return a fully signed 32-bit exit code. Use the GetExitCode method. But this is a bit complicated because the return value is not an exit code (this is the return value of the GetExitCodeProcess Windows function , which indicates the success or failure of the function). The exit code is stored in a variable that you pass to the method.

 use Win32::Process; use Win32; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } my $ProcessObj; Win32::Process::Create($ProcessObj, "C:\\winnt\\system32\\notepad.exe", "notepad temp.txt", 0, NORMAL_PRIORITY_CLASS, ".") or die ErrorReport(); $ProcessObj->Wait(INFINITE); my $exitCode; $ProcessObj->GetExitCode($exitCode) or die ErrorReport(); 
+6
source

Maybe, but it’s not easy.

The Win32::API module can display Windows API scripts for Perl. Use it to create a link to the GetExitCodeProcess function GetExitCodeProcess , call it with the process ID of the dead program, and unzip the result.

+4
source