Perl and waiting for execution of external program

jonas.andersson_at_rocketmail.com
Date: 01/19/05


Date: 19 Jan 2005 07:14:38 -0800

Hi,

Sometimes, when running an external program through Perl, I run into
problems:

...
open (PROG, "|$MyProgram &> /dev/null") or die "cannot open
program"

print PROG "Load file $FileName\n";
print PROG "Calculate all\n";

close (PROG) or die "cannot close program";
...

It sometimes happens that Perl does not wait for the (lengthy)
calculations to finish, but tries to close the program prematurely. (At
least, that is what the symptoms look like).

Is there a way to force Perl to wait for the program to finish before
it tries to close it, however long it takes?

Thanks for your time,

JA



Relevant Pages

  • Linux Magazin: Perl gewinnt haushoch gegen die anderen Skriptsprachen
    ... [@Randal, in case your German's not so good: I was dismayed how they turned this contest around, to make it seem at first sight like you and Perl had completely failed. ... Klar ist es blöd, daß alle nach dem Motto programmieren, CPU und Speicher seien eh da. ... Da ich bei makepp viel Erfahrung mit Perl Optimierung gesammelt habe, bin ich da gerne ran gegangen. ... Randal hat achtlos die drei Infos pro Fußnote in einen Hash gespeichert. ...
    (comp.lang.perl.misc)
  • Re: trying to understand fork and wait
    ... > the perldoc for fork ... ... die had nothing to do with your problem. ... off checking whether functions fail: ... Unfortunately there is no one way to test for 'success' in Perl. ...
    (comp.lang.perl.misc)
  • Re: Looking for a critique
    ... S> Uri Guttman wrote: ... S> Much of my code was borrowed from recipe 12.2 of O'Reilly's "Perl ... S> "die unless" idioms, but in this case I wanted to emphasize the fact ... getting burned with reused here doc tokens, that is more a lesson for ...
    (comp.lang.perl.misc)
  • Re: flock - exclusive file locking
    ... O_WRONLY is probably always true then die() will *never* be called. ... Or use the low precedence 'or' operator: ... That error message is not listed in perldiag.pod so it is not a Perl error/warning and it doesn't match any of the error messages in your code above so something other than your Perl program is producing it. ...
    (perl.beginners)
  • Re: I Dont Have Enough Faith to Be a Christian
    ... In perl, it's probably executable. ... kill spiders, pop them, chop, split, kill them. ... unlink arms, shift, wait & listen (listening, wait), ... die to reverse the system ...
    (uk.rec.sheds)