Video stuck on system(1, @commands) in Perl script
media, perl, system, windows, windows-media-player
Solution
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"});
Problem
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!