Skip to main content.
home | support | download

Back to List Archive

Re: Running programs on Windows

From: Anthony Baratta <Anthony(at)not-real.2plus2partners.com>
Date: Tue Sep 28 2004 - 21:38:22 GMT
Bill Moseley wrote:

> On Tue, Sep 28, 2004 at 09:41:58AM -0700, Anthony Baratta wrote:
> 
>>P.S. The test code you sent me ove the weekend didn't work. ;-( The scan 
>>"locked up" at the same point each time.
> 
> Well, what about something simple like this:

With the changes I saw this in the out put:

4752 Warning - http://local.dev.port.com/pdf/publ_notice2.pdf: Use of 
uninitialized value in waitpid at 
C:\Progra~1\SWISH-E\lib\swish-e\perl/SWISH/Filter.pm line 1119.
4752 Warning - http://local.dev.port.com/pdf/publ_notice2.pdf: Use of 
uninitialized value in waitpid at 
C:\Progra~1\SWISH-E\lib\swish-e\perl/SWISH/Filter.pm line 1119.

Here is the run_program() subroutine:

sub run_program {
     my $self = shift;

     die "No arguments passed to run_program()\n"
         unless @_;

     die "Must pass arguments to program '$_[0]'\n"
         unless @_ > 1;

     my $fh = $^O =~ /Win32/i || $^O =~ /VMS/i
          ? $self->windows_fork( @_ )
          : $self->real_fork( @_ );

     local $/ = undef;

     my $output = <$fh>;
     close $fh;
     waitpid $self->{pid}, 0 if delete $self->{pid};

     #return <$fh>;
     return $output;
}

The window_fork() subroutine still has

	$self->{pid} = $pid;

So I changed one line:

     waitpid -1, 0 if delete $self->{pid};

That ended up with the same lockup behaviour as earlier. ;-( Can you 
explain that line? To me it reads "do waitpid if I can delete 
$self->(pid)", which seems to be that $self->(pid) is deleted before it 
can be used by waitpid.
Received on Tue Sep 28 14:38:45 2004