Blocking.pm: call abortFn if the process dies prematurely

git-svn-id: https://svn.fhem.de/fhem/trunk@15172 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig
2017-10-02 11:46:11 +00:00
parent 4f99147f6d
commit 8e692771ce

View File

@@ -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}) {