perl でバックグラウンド プロセスを実行しようとしています。別の perl スクリプトを呼び出すために使用される子プロセスを作成します。この子プロセスと並行して数行のコードを実行したいと考えています。子プロセスが完了したら、コード行を出力したいと思います。
メインスクリプト
#!/usr/bin/perl
$|=1;
print "before the child process\n";
my $pid = fork();
if (defined $pid)
{
system("perl testing.pl");
}
print "before wait command\n";
wait();
print "after 20 secs of waiting\n";
testing.pl
#!/usr/bin/perl
print "inside testing\n";
sleep(20);
期待される出力
子プロセスの前に 待機コマンドの前 (20 秒待ってから印刷する必要があります) 20 秒待った後