Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
"Does exactly the same thing as "exec LIST", except that a fork is done first, and the parent process waits for the child process to complete."
I recently wrote a perl program:
I expected these to get executed sequentially. Instead, the program started, let's just say "a lot," of these simultaneously, leading to a significant disaster.#!/usr/bin/perl -w use strict; [set up some stuff] foreach my $val (@vals) { [set up some more stuff] system "/usr/bin/mplayer -arg1 -arg2 $file"; }
I eventually got around this by slamming a sleep statement in the loop, but I want to know what I missed, or basically why it didn't behave as I expected (allowing mplayer to finish executing before continuing).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The system command and waiting for the child process to finish
by betterworld (Curate) on Sep 29, 2008 at 11:38 UTC | |
|
Re: The system command and waiting for the child process to finish
by Corion (Patriarch) on Sep 29, 2008 at 10:41 UTC | |
|
Re: The system command and waiting for the child process to finish
by JavaFan (Canon) on Sep 29, 2008 at 11:04 UTC | |
|
Re: The system command and waiting for the child process to finish
by Fletch (Bishop) on Sep 29, 2008 at 15:22 UTC |