[mythtv-users] CTRL-ALT-BACKSPACE -> multiple instances of mythfrontend

Stephen Worthington stephen_agent at jsw.gen.nz
Mon Mar 11 02:31:07 UTC 2019


On Sun, 10 Mar 2019 14:59:19 -0700, you wrote:

>I added a 10 second delay and the problem is gone, no duplicate instances
>of myth. Maybe 3 seconds would work but definitely a race condition.  Other
>than the delay, the code is the same as original.
>
>In fairness to the code, my test is not real life.  Typically if I were to
>do a CTRL-ALT-BS it would be because myth was frozen or missing. I don't
>know that I ever did a CTRL-ALT-BS just as a test with Myth running. The
>timing might be different and the service might be killed faster if it is
>actually frozen. Or maybe I am wrong and this really is an issue.  Either
>way, it should not keep piling on instances of mythfrontend.  But at least
>I think we know what is going on now.
>
>Allen

Using a delay to fix a race condition is usually a bad idea -
something happens which changes the timing, such as a bit of swapping
going on, and then the problem is back again.

Unfortunately, mythfrontend does die quite often for me.  The usual
cause is playing a downloaded video file.  I have quite a few that it
can not handle, and either it dies, or locks up and I have to kill it.
Some of the deaths leave behind "assert failed" messages.  But if you
do not normally play such files, then mythfrontend can be very
reliable and not need the wrapper script.

It looks like the wrapper script needs to be able to detect that the
script itself is still running and to exit if it can see another copy
of itself.  This should work to do that:

pid=$(ps -ef | grep '/bin/sh /usr/bin/mythfrontend --service' | grep
-v grep | awk '{print $2}')
if [ ${#pid} -ne 0 ]; then
    exit 0
fi


More information about the mythtv-users mailing list