<div dir="auto">I agree. Will try your new script tomorrow. Races are nasty and the best way to deal with them is to "fix" the race.  That is a pun. Sorry about the top post but......<div dir="auto"><br></div><div dir="auto">Allen</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 10, 2019, 7:31 PM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz" target="_blank" rel="noreferrer">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, 10 Mar 2019 14:59:19 -0700, you wrote:<br>
<br>
>I added a 10 second delay and the problem is gone, no duplicate instances<br>
>of myth. Maybe 3 seconds would work but definitely a race condition.  Other<br>
>than the delay, the code is the same as original.<br>
><br>
>In fairness to the code, my test is not real life.  Typically if I were to<br>
>do a CTRL-ALT-BS it would be because myth was frozen or missing. I don't<br>
>know that I ever did a CTRL-ALT-BS just as a test with Myth running. The<br>
>timing might be different and the service might be killed faster if it is<br>
>actually frozen. Or maybe I am wrong and this really is an issue.  Either<br>
>way, it should not keep piling on instances of mythfrontend.  But at least<br>
>I think we know what is going on now.<br>
><br>
>Allen<br>
<br>
Using a delay to fix a race condition is usually a bad idea -<br>
something happens which changes the timing, such as a bit of swapping<br>
going on, and then the problem is back again.<br>
<br>
Unfortunately, mythfrontend does die quite often for me.  The usual<br>
cause is playing a downloaded video file.  I have quite a few that it<br>
can not handle, and either it dies, or locks up and I have to kill it.<br>
Some of the deaths leave behind "assert failed" messages.  But if you<br>
do not normally play such files, then mythfrontend can be very<br>
reliable and not need the wrapper script.<br>
<br>
It looks like the wrapper script needs to be able to detect that the<br>
script itself is still running and to exit if it can see another copy<br>
of itself.  This should work to do that:<br>
<br>
pid=$(ps -ef | grep '/bin/sh /usr/bin/mythfrontend --service' | grep<br>
-v grep | awk '{print $2}')<br>
if [ ${#pid} -ne 0 ]; then<br>
    exit 0<br>
fi<br>
_______________________________________________<br>
mythtv-users mailing list<br>
<a href="mailto:mythtv-users@mythtv.org" rel="noreferrer noreferrer" target="_blank">mythtv-users@mythtv.org</a><br>
<a href="http://lists.mythtv.org/mailman/listinfo/mythtv-users" rel="noreferrer noreferrer noreferrer" target="_blank">http://lists.mythtv.org/mailman/listinfo/mythtv-users</a><br>
<a href="http://wiki.mythtv.org/Mailing_List_etiquette" rel="noreferrer noreferrer noreferrer" target="_blank">http://wiki.mythtv.org/Mailing_List_etiquette</a><br>
MythTV Forums: <a href="https://forum.mythtv.org" rel="noreferrer noreferrer noreferrer" target="_blank">https://forum.mythtv.org</a><br>
</blockquote></div>