Re: Problem with Perl system()

Re: Problem with Perl system()

am 19.12.2007 01:26:08 von Julie

Never mind, I answered my own question.

Julie wrote:
> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>
> I have a Perl program that calls another Perl program using system().
>
> The driver program repeatedly calls the main Perl program.
>
> for ( my $i = 0 ; $i < $retries ; $i++
> {
> for ( my $j = 0 ; $j < $num_devices ; $j++ )
> {
> system( "perl main.pl parm1 parm2 &" ) ;
> }
> sleep 60 ; # never gets here
> }
>
> I put the call to system() within a loop and (almost) everything is fine.
>
> The only problem is that after the last call to system(), the outer loop
> doesn't gain control. The process seems to be hung.
> I've put warn statements everywhere in the driver program but that
> hasn't yielded any clues.
>
> I know that main.pl is terminating because there's only one Perl process
> running after the last call to system().
>
> It doesn't matter whether I run one or a hundred calls to system().
>
> **** Here's what's very interesting: If I run main.pl under the Perl
> debugger then press 'c' to continue (no breakpoints etc.), then the
> program behaves perfectly; control is passed to the outer loop after the
> last system() call.
>
> I'm using strict, warning, diagnostics pragmas. I've also tried main.pl
> without the pragmas.
>
> What can I do to resolve this problem?

Re: Problem with Perl system()

am 19.12.2007 02:21:25 von spambait

In article <47686516$0$1383$4c368faf@roadrunner.com>, Julie wrote:
>Never mind, I answered my own question.

well, what was the answer?
>
>Julie wrote:
>> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>>
>> I have a Perl program that calls another Perl program using system().
>>
>> The driver program repeatedly calls the main Perl program.
>>
>> for ( my $i = 0 ; $i < $retries ; $i++
>> {
>> for ( my $j = 0 ; $j < $num_devices ; $j++ )
>> {
>> system( "perl main.pl parm1 parm2 &" ) ;
>> }
>> sleep 60 ; # never gets here
>> }
>>
>> I put the call to system() within a loop and (almost) everything is fine.
>>
>> The only problem is that after the last call to system(), the outer loop
>> doesn't gain control. The process seems to be hung.
>> I've put warn statements everywhere in the driver program but that
>> hasn't yielded any clues.
>>
>> I know that main.pl is terminating because there's only one Perl process
>> running after the last call to system().
>>
>> It doesn't matter whether I run one or a hundred calls to system().
>>
>> **** Here's what's very interesting: If I run main.pl under the Perl
>> debugger then press 'c' to continue (no breakpoints etc.), then the
>> program behaves perfectly; control is passed to the outer loop after the
>> last system() call.
>>
>> I'm using strict, warning, diagnostics pragmas. I've also tried main.pl
>> without the pragmas.
>>
>> What can I do to resolve this problem?

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.

Re: Problem with Perl system()

am 19.12.2007 05:51:56 von John Bokma

Julie wrote:

> Never mind, I answered my own question.

Don't top post. And it's always polite if you ask others for help, and
found the solution yourself to post the solution.

--
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1. html

Re: Problem with Perl system()

am 19.12.2007 10:31:43 von Joe Smith

> Julie wrote:
>> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>>...
>> What can I do to resolve this problem?

Julie wrote:
> Never mind, I answered my own question.

But the answer is not obvious to us.
What did you do to resolve your problem?

Re: Problem with Perl system()

am 19.12.2007 12:33:44 von Julie

Doug Miller wrote:
> In article <47686516$0$1383$4c368faf@roadrunner.com>, Julie wrote:
>> Never mind, I answered my own question. >
> well, what was the answer?

see below

>> Julie wrote:
>>> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>>>
>>> I have a Perl program that calls another Perl program using system().
>>>
>>> The driver program repeatedly calls the main Perl program.
>>>
>>> for ( my $i = 0 ; $i < $retries ; $i++
>>> {
>>> for ( my $j = 0 ; $j < $num_devices ; $j++ )
>>> {
>>> system( "perl main.pl parm1 parm2 &" ) ;
>>> }
>>> sleep 60 ; # never gets here
>>> }
>>>
>>> I put the call to system() within a loop and (almost) everything is fine.
>>>
>>> The only problem is that after the last call to system(), the outer loop
>>> doesn't gain control. The process seems to be hung.
>>> I've put warn statements everywhere in the driver program but that
>>> hasn't yielded any clues.
>>>
>>> I know that main.pl is terminating because there's only one Perl process
>>> running after the last call to system().
>>>
>>> It doesn't matter whether I run one or a hundred calls to system().
>>>
>>> **** Here's what's very interesting: If I run main.pl under the Perl
>>> debugger then press 'c' to continue (no breakpoints etc.), then the
>>> program behaves perfectly; control is passed to the outer loop after the
>>> last system() call.
>>>
>>> I'm using strict, warning, diagnostics pragmas. I've also tried main.pl
>>> without the pragmas.
>>>
>>> What can I do to resolve this problem?
>

I replaced all the 'print' statements with 'warn' statements to let me
know what the program was doing.

I thought that I had added enough print/warn statements to inform me
that the program was sleeping before its next iteration.

For whatever reason, when running the program under the debugger (not in
step mode or with any watch or breakpoints but 'c' which ran the entire
program), all the print statements are displayed. When not running in
debug mode, not all the print statements were being displayed.

Obviously, this is not a 'solution' but an artifact and I don't know if
it's because I'm running under Cygwin. I normally would have spend more
time trying to resolve this issue on my own but I had a deadline.

Re: Problem with Perl system()

am 19.12.2007 13:10:37 von Tad J McClellan

Julie wrote:

> I replaced all the 'print' statements with 'warn' statements to let me
> know what the program was doing.
>
> I thought that I had added enough print/warn statements to inform me
> that the program was sleeping before its next iteration.
>
> For whatever reason,


Suffering from Buffering?

http://perl.plover.com/FAQs/Buffering.html


> when running the program under the debugger (not in
> step mode or with any watch or breakpoints but 'c' which ran the entire
> program), all the print statements are displayed. When not running in
> debug mode, not all the print statements were being displayed.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"