summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oetiker <tobi@oetiker.ch>2012-03-22 23:00:25 +0100
committerTobias Oetiker <tobi@oetiker.ch>2012-03-22 23:00:25 +0100
commit82162859fa9bc528fedf284e5bf6618ae98f1a7d (patch)
tree00518ff87dd2d403ca6fe4bfe6bbee07c0036bae
parentc3539403a5ba22a633488764a68200a06aa3ba95 (diff)
downloadsmokeping-82162859fa9bc528fedf284e5bf6618ae98f1a7d.tar.gz
smokeping-82162859fa9bc528fedf284e5bf6618ae98f1a7d.tar.xz
fork alert handlers, so that smokeping does not block
-rw-r--r--lib/Smokeping.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index bba6dca..f5743c0 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -1872,10 +1872,18 @@ sub check_alerts {
next unless $addr;
if ( $addr =~ /^\|(.+)/) {
my $cmd = $1;
- if ($edgetrigger) {
- system $cmd,$_,$line,$loss,$rtt,$tree->{host}, ($what =~/raise/);
- } else {
- system $cmd,$_,$line,$loss,$rtt,$tree->{host};
+ # fork them in case they
+ unless ($pid = fork) {
+ unless (fork) {
+ $SIG{CHLD} = 'DEFAULT';
+ if ($edgetrigger) {
+ exec $cmd,$_,$line,$loss,$rtt,$tree->{host}, ($what =~/raise/);
+ } else {
+ exec $cmd,$_,$line,$loss,$rtt,$tree->{host};
+ }
+ die "exec failed!";
+ }
+ exit 0;
}
}
elsif ( $addr =~ /^snpp:(.+)/ ) {