2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 07:19:24 +00:00

01_FHEMWEB.pm: Implement asyncCmd: fork if set (Forum #108952)

git-svn-id: https://svn.fhem.de/fhem/trunk@21359 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-03-05 17:00:43 +00:00
parent ec3bd5e768
commit ff926140d2

View File

@ -919,6 +919,22 @@ FW_answerCall($)
#If we are in XHR or json mode, execute the command directly #If we are in XHR or json mode, execute the command directly
if($FW_XHR || $FW_jsonp) { if($FW_XHR || $FW_jsonp) {
if($FW_webArgs{asyncCmd}) {
my $pid = fhemFork();
if($pid) { # success, parent
TcpServer_Disown( $me );
delete($defs{$FW_cname});
delete($attr{$FW_cname});
FW_Read($me, 1) if($me->{BUF});
return -2;
} elsif(defined($pid)){ # child
delete $me->{BUF};
$me->{isChild} = 1;
}
}
$FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : undef; $FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : undef;
$FW_RETTYPE = $FW_chash->{contenttype} ? $FW_RETTYPE = $FW_chash->{contenttype} ?
$FW_chash->{contenttype} : "text/plain; charset=$FW_encoding"; $FW_chash->{contenttype} : "text/plain; charset=$FW_encoding";