in reply to Problem with exit status of bash script
Something like that:
Output:use strict; use warnings; use autodie; use POSIX ':sys_wait_h'; my @sites = qw( www.perlmonks.org www.stackoverflow.com www.whitehouse.gov ); open my $stdout, '>&', \*STDOUT; # dup STDOUT open STDOUT, '>', '/dev/null'; # to make ping shut up my %kids; for my $site (@sites) { my $pid = fork; $pid == 0 and exec 'ping', '-c', '3', $site; $kids{$pid} = $site; } while ( ( my $kid = wait ) != -1 ) { print $stdout "$kids{$kid} returned $?\n"; }
www.stackoverflow.com returned 0 www.perlmonks.org returned 0 www.whitehouse.gov returned 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with exit status of bash script
by dizzyd719 (Novice) on Dec 05, 2014 at 00:31 UTC | |
by Anonymous Monk on Dec 05, 2014 at 01:50 UTC | |
by dizzyd719 (Novice) on Dec 05, 2014 at 02:14 UTC | |
by Anonymous Monk on Dec 05, 2014 at 02:37 UTC |