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

I'm trying to use the system() function on a win32 machine to run a DOS command and capture its error code. It seems like the return value is overflowing, though, if it's any greater than 255. I tested with this sample program:
$num = 256; $res = system('exit /b $num'); print $res/256;
For values of $num less than 256, it works as expected. Anything higher, and it doesn't. Is this a limitation of win32 Perl? Is there a workaround?

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re: system() return values overflowing on win32?
by clintp (Curate) on Sep 13, 2001 at 04:20 UTC
    My bet is that MS-Windows has the same restriction as MS-DOS which is also limited to 8 bits. That's what my documentation on ERRORLEVEL says from DOS-3.3.

    Unix is certainly limited to 8-bits of exit status from a program. (Well more if it drops core, it was signaled, etc... but you get the idea.)