#!/usr/bin/perl -w use 5.011; use Net::Ping; my $start = time; if ( fork() == 0 ) { # arm the alarm clock alarm(5); my @sites = qw/www.google.com www.merrillpjensen.com www.perlmonks.org/; for my $host (@sites) { my $p = Net::Ping->new(); print "$host is alive.\n" if $p->ping($host); $p->close(); } exit(0); } say "relevant processes with pstree command:"; system("pstree -Apal $$"); while ( ( my $pid = wait() ) != -1 ) { say "$pid terminated"; } #system("cat 7.fork.txt"); say time - $start, " ? seconds elapsed from forked process" __END__