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

Allen Edwards allen.p.edwards at gmail.com
Mon Mar 11 16:41:08 UTC 2019


On Sun, Mar 10, 2019 at 7:31 PM Stephen Worthington <
stephen_agent at jsw.gen.nz> wrote:

> 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
> _______________________________________________
>
> I do not understand why this does not work but I am no script expert so I
am not sure what exactly is going on with ${#pid} and how that relates to
the initial pid. Perhaps there is a $ missing or misplaced on the first
line?  I did run some tests.

*dad at NewMyth:~$ ps -ef | grep '/bin/sh /usr/bin/mythfrontend --service' |
grep -v grep*
*dad       2310     1  0 09:17 ?        00:00:00 /bin/sh
/usr/bin/mythfrontend --service*
*dad       2605     1  0 09:17 ?        00:00:00 /bin/sh
/usr/bin/mythfrontend --service*
*dad       2961  2939  0 09:17 ?        00:00:00 /bin/sh
/usr/bin/mythfrontend --service*

And

*dad at NewMyth:~$ ps -ef | grep '/bin/sh /usr/bin/mythfrontend --service' |
grep -v grep | awk '{print $2}'*
*2310*
*2605*
*2961*

For now I will just run mythfrontend without the --service option.  That
should be fine for my needs. I am still willing to troubleshoot this if you
think that would be useful so let me know.

I wish to thank both Stephen and Ian for your help.

Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20190311/c8c34a84/attachment.html>


More information about the mythtv-users mailing list