Subject: | Croak if system() returns -1 or 0xFF00 |
On ActiveState perl 5.8.8[1] under Win32, system() seems to returns
0xFF00 when executing a bogus command, so this script:
use IPC::Run3;
print "ok\n" if run3 [ "not a valid command" ];
warn "\$?: $?\n";
prints:
ok
$?: 65280
The below patch (full patch attached) checks for system() returning
0xFF00 on Win32 (I assume it's platform-specific). I will apply this
patch to 0.042 at some point if noone objects; however, I want to give
others a chance to think about any issues this might cause before
(possibly) breaking running code. The croak() part should definitely be
added.
The patch also uses croak() to give the user a more helpful location:
- die $! if defined $r && $r == -1 &&
!$options->{return_if_system_error};
+ if (
+ defined $r
+ && ( $r == -1 || ( is_win32 && $r == 0xFF00 ) )
+ && !$options->{return_if_system_error}
+ ) {
+ require Carp;
+ Carp::croak( $errno );
+ }
[1] perl -v:
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 18 registered patches, see perl -V for more detail)
Copyright 1987-2007, Larry Wall
Binary build 822 [280952] provided by ActiveState http://www.ActiveState.com
Built Jul 31 2007 19:34:48
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Subject: | 0xFF00_and_croak.patch |
--- c:\perl\site\lib\IPC\Run3.pm Sun May 24 16:10:58 2009
+++ lib\IPC\Run3.pm Sun May 24 16:43:24 2009
@@ -419,7 +419,14 @@
}
}
- die $! if defined $r && $r == -1 && !$options->{return_if_system_error};
+ if (
+ defined $r
+ && ( $r == -1 || ( is_win32 && $r == 0xFF00 ) )
+ && !$options->{return_if_system_error}
+ ) {
+ require Carp;
+ Carp::croak( $errno );
+ }
1;
};