activeperl@listserv.activestate.com
[Top] [All Lists]

RE: windows: exit status 66 in $? after pipe close

Subject: RE: windows: exit status 66 in $? after pipe close
From: "Brian Raven"
Date: Thu, 27 Apr 2006 10:27:36 +0100
Warren Burstein <> wrote:
> A Windows 2000 computer running ActivePerl build 631 occasionally
> (something like every few weeks, it does thousands of these on most
> days with no problem) opens a pipe from another perl script, gets no
> input from the pipe, close fails on the filehandle, $! is false, and
> $?    
> contains 0x100 * 66 which should mean that perl's exit status was 66.
> 
> Windows error 66 is not defined in the errno.h that comes with MSVC
> 6, but "net helpmsg 66" prints "The network resource type is not
> correct.".  I don't know if there's any connection between that error
> and the one I'm getting.  The perl script, and perl.exe are on local
> drives so I don't understand how a network error could result.    
> 
> I can't see how either perl or my script could return an exit status
> of 66.  perl will return the error code if it can't open the file,
> but I can only see how that could be 2 (ENOENT) or 13 (EACCESS).  And
> perl would print an error message, which would get logged to a file,
> and that isn't happening.  Likewise, my perl script will always print
> something to a log file at startup and before exiting and that isn't
> happening. But the logfile is getting written to - that's where I
> found the error 66 in the first perl script.  So I wonder if the
> error is coming from somewhere in the implementation of open().      
> 
> I looked at the pipe code in the sources (in win32/win32.c), and
> don't see how anything other than a windows error code or the exit
> status from my command could wind up in $?, but I don't know how
> either of those could be 66 (and even if perl or my script did
> exit(66), why an error message doesn't get read from the pipe).    
> 
> Has anyone seen this before?  And has it been fixed in a later
> release of ActivePerl?  Or if it's not a bug, what it means? If it
> happened daily, I'd just upgrade and see if it stopped, but since the
> problem occurs so rarely, it will take a few months before I have
> even a small degree of confidence that it helped.    
> 
> Here is the code.  I'm leaving out the details of how the output gets
> into a log file. 
> 
> if ( !open(PIPE, "perl $PATH/faxrpt.pl 2>&1|")) {
>   die "pipe failed, $!\n";
> }
> while (<PIPE>) {
>   print;
> }
> if ( !close(PIPE)) {
>   if ($!) {
>      warn "error closing pipe, $!\n";
>   } else {
>     if ($? >= 0x100) {
>       $s = $? / 0x100;
>       warn("exit status $s\n");
>     } else {
>       warn "signal $?\n";
>     }
>   }

If perl exits due to a compilation error, or run time failure, or a die
statement, the exit code is -1 (i.e. $? would contain 0xff00 in your
calling program). If the exit status is 0x4200, then there is probably
an exit statement in $PATH/faxrpt.pl, or something that it calls, that
is causing it. I have not used that version of Perl for a long time, but
as far as I can remember that is the way it has always worked.

Also, in general, program exit codes have no relation to system error
numbers, unless you explicitly make it so.

HTH

-- 
Brian Raven 


=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
ActivePerl@xxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

<Prev in Thread] Current Thread [Next in Thread>