I'm trying to write a Perl script that runs videos in a directory n times on Windows Media Player one after the other.
For some reason, on the 64th video playing, it gets stuck on system(1, @commands).
Right now, the command is system(1, "C:\\Program Files (x86)\\Windows Media Player\\wmplayer", $path); in the following for-loop.
for (my $i = 0; $i < $n; $i++)
{
# do stuff
# Play video
system(1, "C:\\Program Files (x86)\\Windows Media Player\\wmplayer", $path);
sleep $duration + 1;
# do stuff
}
I'm wondering why it keeps stopping at the 64th video (I've run this multiple times and it's always the 64th.) Maybe someone can explain system(1, @commands) better to me? All I know is that it just doesn't wait for @commands to finish before continuing the program...
Thanks a lot!
You've reached the maximum number of child processes you can have running simultaneously. Reap those that have completed using waitpid.
Alternatively, if you don't care about the process's exit code, you might have better luck with
system(qq{start /b "" "c:\...\wmplayer" "$path"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With