From 8e692771ce5287d4c1b069ee27ede498ce6f7d60 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Mon, 2 Oct 2017 11:46:11 +0000 Subject: [PATCH] Blocking.pm: call abortFn if the process dies prematurely git-svn-id: https://svn.fhem.de/fhem/trunk@15172 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/Blocking.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/Blocking.pm b/fhem/FHEM/Blocking.pm index 0d5a78449..501c280ca 100644 --- a/fhem/FHEM/Blocking.pm +++ b/fhem/FHEM/Blocking.pm @@ -137,6 +137,11 @@ BlockingStart(;$) } if(!kill(0, $h->{pid})) { $h->{pid} = "DEAD:$h->{pid}"; + if(!$h->{terminated} && $h->{abortFn}) { + no strict "refs"; + my $ret = &{$h->{abortFn}}($h->{abortArg},"Process died prematurely"); + use strict "refs"; + } delete($BC_hash{$bpid}); RemoveInternalTimer($h) if($h->{timeout}); } else { @@ -254,9 +259,11 @@ BlockingKill($) if($h->{pid} && $h->{pid} !~ m/:/ && kill(9, $h->{pid})) { my $ll = (defined($h->{loglevel}) ? $h->{loglevel} : 1); # Forum #77057 Log $ll, "Timeout for $h->{fn} reached, terminated process $h->{pid}"; + $h->{terminated} = 1; if($h->{abortFn}) { no strict "refs"; - my $ret = &{$h->{abortFn}}($h->{abortArg}); + my $ret = &{$h->{abortFn}}($h->{abortArg}, + "Timeout: process terminated"); use strict "refs"; } elsif($h->{finishFn}) {