所以我有以下代码,问题是它在所有子进程(排序/gzip)完成之前就退出了。如何指示 Perl 等待所有后代进程?
#!/usr/bin/perl
use strict;
use warnings;
sub systemBash {
my $cmd = shift;
my @args = ( "bash", "-c", $cmd );
print "command ".$cmd."\n";
system(@args);
if($? != 0){
die "Command ".Dumper(@args)." failed";
}
}
print "start";
systemBash("yes |head -n 1000000|awk '{print rand()}' > >(sort |gzip -9 -c > /dev/null)");
print "done";