Perl has a finer control over forking than any shell. It rivals the system C libraries in that regard. You may enjoy comparing your code to perl's native system calls for the job.
my %kid; for (@commands) { defined(my $cpid = fork) or sleep 1, redo; $cpid and $kid{$cpid} = 1, next; # parent %kid = (); # child exec '/bin/bash', '-c', $_; # thanks, ikegami exit 1; } delete $kid{+wait} while %kid; print "@{[times]}\n";
After Compline,
Zaxo
In reply to Re: Using perl to speed up a series of bash commands by transforming them into a single command that will run everything in parallel.
by Zaxo
in thread Using perl to speed up a series of bash commands by transforming them into a single command that will run everything in parallel.
by tphyahoo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |