From 8837a8d3a033a124644d6085555d70afa1372a30 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Mon, 2 Apr 2012 09:20:07 +0200 Subject: wait for the first gen child to terminate --- lib/Smokeping.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm index f5743c0..ec05528 100644 --- a/lib/Smokeping.pm +++ b/lib/Smokeping.pm @@ -1866,13 +1866,14 @@ sub check_alerts { my $rtt = "rtt: ".join ", ",map {defined $_ ? (/^\d/ ? sprintf "%.0fms", $_*1000 :$_):"U" } @{$x->{rtt}}; my $time = time; my @stamp = localtime($time); - my $stamp = localtime($time); - my @to; - foreach my $addr (map {$_ ? (split /\s*,\s*/,$_) : ()} $cfg->{Alerts}{to},$tree->{alertee},$alert->{to}){ - next unless $addr; - if ( $addr =~ /^\|(.+)/) { + my $stamp = localtime($time); + my @to; + foreach my $addr (map {$_ ? (split /\s*,\s*/,$_) : ()} $cfg->{Alerts}{to},$tree->{alertee},$alert->{to}){ + next unless $addr; + if ( $addr =~ /^\|(.+)/) { my $cmd = $1; - # fork them in case they + # fork them in case they take a long time + my $pid; unless ($pid = fork) { unless (fork) { $SIG{CHLD} = 'DEFAULT'; @@ -1885,6 +1886,7 @@ sub check_alerts { } exit 0; } + waitpid($pid, 0); } elsif ( $addr =~ /^snpp:(.+)/ ) { sendsnpp $1, <