Skip Menu |

This queue is for tickets about the IPC-Run3 CPAN distribution.

Report information
The Basics
Id: 95308
Status: open
Priority: 0/
Queue: IPC-Run3

People
Owner: Nobody in particular
Requestors: CHORNY [...] cpan.org
Cc: PLICEASE [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.048
Fixed in: (no value)



Subject: "Inappropriate I/O control operation" error breaks Test-Script-Run-0.08 with IPC-Run3-0.048
No such error with 0.046. https://rt.cpan.org/Ticket/Display.html?id=95195 also Test-Script-1.07 has this problem: https://rt.cpan.org/Ticket/Display.html?id=94685 and Perl::Dist::Strawberry, not in tests, but when generating Strawberry. -- Alexandr Ciornii, http://chorny.net
Am 2014-05-03 04:42:35, CHORNY schrieb: Show quoted text
> No such error with 0.046. > https://rt.cpan.org/Ticket/Display.html?id=95195 > also Test-Script-1.07 has this problem: > https://rt.cpan.org/Ticket/Display.html?id=94685 > > and Perl::Dist::Strawberry, not in tests, but when generating > Strawberry.
The problem in IPC/Run3.pm is this (paraphrasing a bit): my $r = system @$cmd; if ( defined $r && ( $r == -1 || ( is_win32 && $r == 0xFF00 ) ) && !$options->{return_if_system_error} ) { croak( $! ); } It's the Windows-only check $r == 0xFF00 (i.e. 255<<8 ). It's supposed to signal a problem in spawning the command, cf. http://search.cpan.org/~rjbs/perl-5.18.1/pod/perlport.pod#system Unfortunately this makes it undistinguishable from the case where the command runs, but returns status 255, as is the case when it die's. E.g. on Windows, using Strawberry 5.18.1: $ perl -E "my $r = system $^X, '-e', 'die'; say qq[\$r=$r \$?=$? \$!=$!]" Died at -e line 1. $r=65280 $?=65280 $!= Actually, the documentation seems to be out of date: $ perl -E "my $r = system 'frobozz'; say qq[\$r=$r \$?=$? \$!=$!]" Der Befehl "frobozz" ist entweder falsch geschrieben oder konnte nicht gefunden werden. $r=256 $?=256 $!=No such file or directory So system() returns neither the general result (-1) for this error, nor the Windows-specific one (255<<8). BTW, the "Inappropriate I/O control operation" in the bug report is a red herring: this $! was encountered long before system() was called (most likely in File::Temp::temfile()), but you're only allowed to look at $! if a function actually reports an error. Cheers, Roderich
On 2014-05-04 07:48:12, RSCHUPP wrote: Show quoted text
> Actually, the documentation seems to be out of date: > > $ perl -E "my $r = system 'frobozz'; say qq[\$r=$r \$?=$? \$!=$!]" > Der Befehl "frobozz" ist entweder falsch geschrieben oder konnte nicht > gefunden werden. > $r=256 $?=256 $!=No such file or directory > > So system() returns neither the general result (-1) for this error, > nor the Windows-specific one (255<<8).
Sorry, spoke too soon. system first tries to directly spawn the non-existent program. Failing that it tries to run it via the Windows shell. That's where $r == 256 comes from. Use "system { cmd } cmd, arg, ..." to suppress this fallback (and that is what run3() actually does): $ perl -E "my $r = system { 'frobozz' } 'frobozz'; say qq[\$r=$r \$!=$! \$?=$?]" $r=65280 $!=No such file or directory $?=65280 So the documentation is correct :) Suggested fix attached: - check $errno (i.e. $!) if (on Windows) system() returns 0xFF00 - make sure that $! was set by system() (i.e. is not some leftover from a previous system call)
Subject: Run3.patch
--- a/IPC/Run3.pm 2014-05-05 09:59:33.001090000 +0200 +++ b/IPC/Run3.pm 2014-05-05 09:59:21.366926700 +0200 @@ -399,6 +399,8 @@ $sys_call_time = gettimeofday() if profiling; + $! = 0; # make sure we don't test below against some previous error + my $r = ref $cmd ? system { $cmd->[0] } is_win32 ? quote_native( @$cmd ) : @$cmd : system $cmd; @@ -416,7 +418,7 @@ if ( defined $r - && ( $r == -1 || ( is_win32 && $r == 0xFF00 ) ) + && ( $r == -1 || ( is_win32 && $r == 0xFF00 && $errno != 0 ) ) && !$options->{return_if_system_error} ) { croak( $errno );
On Mon May 05 04:16:10 2014, RSCHUPP wrote: Show quoted text
> Suggested fix attached: > - check $errno (i.e. $!) if (on Windows) system() returns 0xFF00 > - make sure that $! was set by system() (i.e. is not some leftover > from a previous system call)
I've created a PR here, in the hopes that this fix can be more easily merged: https://github.com/rjbs/IPC-Run3/pull/9 that addresses this with the given patch and a test that demonstrates the problem.