in reply to Re^2: Can't spawn "cmd.exe":
in thread Can't spawn "cmd.exe":

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.

Replies are listed 'Best First'.
Re^4: Can't spawn "cmd.exe":
by BrowserUk (Patriarch) on Mar 19, 2009 at 14:16 UTC