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

Allen Edwards allen.p.edwards at gmail.com
Sun Mar 10 21:59:19 UTC 2019


On Sun, Mar 10, 2019 at 12:49 PM Allen Edwards <allen.p.edwards at gmail.com>
wrote:

> On Sun, Mar 10, 2019 at 9:50 AM Allen Edwards <allen.p.edwards at gmail.com>
> wrote:
>
>> Hi Ian and Stephen,
>>
>> You guys were busy as I slept so I am creating a single response.
>>
>> As to what I am running this is what I know
>>
>> *dad at NewMyth:~$ lsb_release -a*
>> *No LSB modules are available.*
>> *Distributor ID: Ubuntu*
>> *Description:    Ubuntu 16.04.1 LTS*
>> *Release:        16.04*
>> *Codename:       xenial*
>>
>>
>> *dad at NewMyth:~$ apt-cache policy mythtv*
>> *mythtv:*
>> *  Installed: 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2*
>> *  Candidate: 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2*
>> *  Version table:*
>> * *** 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2 500*
>> *        500 http://ppa.launchpad.net/mythbuntu/0.28/ubuntu
>> <http://ppa.launchpad.net/mythbuntu/0.28/ubuntu> xenial/main i386 Packages*
>> *        100 /var/lib/dpkg/status*
>> *     2:0.28.0+fixes.20160413.15cf421-0ubuntu2 500*
>> *        500 http://us.archive.ubuntu.com/ubuntu
>> <http://us.archive.ubuntu.com/ubuntu> xenial/multiverse i386 Packages*
>>
>>
>> And to Ian's question:
>>
>> *dad at NewMyth:~$ ls -la /home/dad/.config/autostart*
>> *total 16*
>> *drwxrwxr-x  2 dad dad 4096 Oct 14 09:22 .*
>> *drwxrwxr-x 12 dad dad 4096 Feb 24 17:14 ..*
>> *lrwxrwxrwx  1 dad dad   38 Aug 25  2018 mythtv.desktop ->
>> /usr/share/applications/mythtv.desktop*
>> *-rw-rw-r--  1 dad dad   30 Oct 14 09:19 pulseaudio.desktop*
>> *-rw-rw-r--  1 dad dad   29 Oct 14 09:22 xfsettingsd.desktop*
>>
>>
>> I must say, I did think your solution of killing mythfrontend via the
>> remote to be a good and elegant one.  Given that a remote is nearly always
>> to hand, it's about as user-friendly as it could be.  So far, we have gone
>> down this rabbit hole a bit - the question now is whether to go further
>> down it or give up...
>>
>> For a number of reasons having to do with what we are used to, the
>> difficulty of programming and using the remote, and the unknowns of
>> changing the lirc code, I prefer to continue on the CTRL-ALT-BS question as
>> I think we are very close to a solution with all the thought you two have
>> put into this. It could also be of benefit to others if a good solution is
>> found.
>>
>> ultimately suggest running mythfrontend without the --service option
>>
>> If Myth is being run by that script from 2007 that doesn't even run
>> correctly I must ask does myth still crash often enough that the auto
>> restart is necessary?  This seems like a super easy solution unless the
>> underlying program crashes constantly. BTW, I tested it and it works.
>>
>> Of course, I may not know if this script is restarting myth but I doubt
>> it as we can see that it does't work.  The crashes I get of myth are freeze
>> up.  Still possible I would not know but worth thought as if the script
>> really is 12 years old then perhaps it is solving a problem that is no
>> longer a problem.
>>
>> Clicking on the Edit button reveals that this runs:
>> *  mythfrontend --service*
>>
>> Correct. What is your opinion on how important the --service is at this
>> point? That script is really old if the comments are correct.
>>
>> If the --service option is necessary am I correct that the suggestion is
>> to change this line
>>
>> *pidof mythfrontend.real 2>&1 >/dev/null && wmctrl -a "MythTV Frontend"
>> 2>/dev/null && exit 0*
>>
>> To this
>>
>> *pidof mythfrontend.real 2>&1 >/dev/null*
>> *pidof_retcode=$?*
>> *if [ $pidof_retcode==0 ]; then*
>> *  wmctrl -a "MythTV Frontend" 2>/dev/null*
>> *  wmctrl_retcode=$?*
>> *else*
>> *  wmctrl_retcode=1*
>> *fi*
>> *if [ pidof_retcode==0 || wmctrl_retcode==0 ]; then*
>> *  exit 0*
>> *fi*
>>
>> By the way, *pidof mythfrontend.real *returns 3524 (the pid) and *wmctrl
>> -a "MythTV Frontend"  *doesn't return anything at least on a terminal
>> but I think that is normal.
>>
>> What I think is going on is that X closes mythfrontend.real but does not
>> close the service.  Then when X opens again and checks if myth is running
>> the service has not had time to get its version of myth running so the pid
>> returns null or 0. This happens so fast and all the services start versions
>> of myth before the pid is valid. One key is that when I do CTRL-ALT-BS I
>> don't always get a new instance, just 80-90% of the time.  This says to me
>> there is a timing component to the problem.  My computer is much faster
>> with the new RAM and my guess is that mostly all the services are busy
>> starting an instance of myth before a pid is established. Perhaps what is
>> needed as the first line of the script is a delay.
>>
>> I will test the proposed script changes when I hear from you that I
>> understand it correctly and continue to think it is a good idea. Until
>> then, I am running mythfrontend without the service option. My gut says
>> that is the best solution anyway.   That script is just too old. I don't
>> trust it and doubt that it is necessary any longer.
>>
>> Allen
>>
>>
> As I said, eliminating the --service from the autostart edit solved the
> problem. I have now tried some edits on the script.
>
> Adding delay to  /usr/share/mythtv/mythfrontend.sh makes it so I only get
> two instances of mythfrontend instead of one more for every restart. That
> says to me there are two mechanisms and adding the delay cured one of them.
> Recall that previously when I did ten restarts I had nine instances of
> mythfrontend running. I thought this was interesting data so wanted to
> share it.  It might help in figuring out what is going on as we descend
> further down the rabbit hole.
>
> Changing the first line to the suggestion in bold above and keeping the
> delay (sleep 1) in was the same as keeping the old code.  I would get 2
> instances of mythfrontend regardless of how many times I did a reset.  That
> does not surprise me as the way I read it, it does the same thing as the
> single line.  The single line relies on the property that the expression is
> evaluated from left to right and only does the next test if the first one
> passes.  It is very clever but also very hard to read.  The suggested edit
> is easier to read but I think does the same thing.
>
> I have reverted back to not running mythfrontend as a service. I continue
> to feel this is the best solution.  That script is old and is basically a
> hack to solve a problem that I would hope is no longer there. But I will
> find out since I am running without it as a service.
>
> There are two possible paths now.  One is to do nothing and see if myth
> crashes and needed the autostart. The other is to continue down the rabbit
> hole and try and solve the problem with the script.  My preference is to
> continue the search for a solution to the script's issues but I do not feel
> strongly one way or the other.
>
> Allen
>

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20190310/d982f5d2/attachment.html>


More information about the mythtv-users mailing list