2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 07:24:21 +00:00

73_MPD:fix finding idle process

git-svn-id: https://svn.fhem.de/fhem/trunk@23900 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Wzut 2021-03-06 18:18:14 +00:00
parent ad89f77b92
commit cb6438bca2

View File

@ -1386,10 +1386,11 @@ sub MPD_watch_idle($)
return if (!defined($hash->{IPID})); return if (!defined($hash->{IPID}));
my $waits = AttrVal($name, "waits", 60); my $waits = AttrVal($name, "waits", 60);
my $cmd = "ps -e | grep '".$hash->{IPID}." '"; #my $cmd = "ps -e | grep '".$hash->{IPID}." '";
my $result = qx($cmd); #my $result = qx($cmd);
if (index($result,"perl") == -1) #if (index($result,"perl") == -1) # https://forum.fhem.de/index.php/topic,119322.msg1137693.html#msg1137693
unless (kill 0, $hash->{IPID})
{ {
Log3 $name, 2 , $name.", cant find idle PID ".$hash->{IPID}." in process list !"; Log3 $name, 2 , $name.", cant find idle PID ".$hash->{IPID}." in process list !";
BlockingKill($hash->{helper}{RUNNING_PID}); BlockingKill($hash->{helper}{RUNNING_PID});
@ -1398,8 +1399,8 @@ sub MPD_watch_idle($)
InternalTimer(gettimeofday()+2, "MPD_try_idle", $hash, 0); InternalTimer(gettimeofday()+2, "MPD_try_idle", $hash, 0);
return; return;
} }
else #else
{ #{
Log3 $name, 5 , $name.", idle PID ".$hash->{IPID}." found"; Log3 $name, 5 , $name.", idle PID ".$hash->{IPID}." found";
if ((ReadingsVal($name,"presence","") eq "present") && if ((ReadingsVal($name,"presence","") eq "present") &&
($hash->{STATE} eq "play") && ($hash->{STATE} eq "play") &&
@ -1410,7 +1411,7 @@ sub MPD_watch_idle($)
mpd_cmd($hash, "status"); mpd_cmd($hash, "status");
readingsSingleUpdate($hash,"playlistname",$hash->{".playlist"},1) if ($hash->{READINGS}{"playlistname"}{VAL} ne $hash->{".playlist"}); readingsSingleUpdate($hash,"playlistname",$hash->{".playlist"},1) if ($hash->{READINGS}{"playlistname"}{VAL} ne $hash->{".playlist"});
} }
} #}
InternalTimer(gettimeofday()+$waits, "MPD_watch_idle", $hash, 0); InternalTimer(gettimeofday()+$waits, "MPD_watch_idle", $hash, 0);
return; return;