PDA

View Full Version : I still miss the old behavior of init 4



Trial
02-06-20, 10:08
Hi,
I still miss the old behavior of init 4 which simply killed E2. I can do the same with kill -9 id-of-enigma2. killall enigma2 does not work I think. Is there a way to put this in a shell script? I can look with PS-A | grep enigma2 but how do I get the id extracted?

I want a script which looks like that:
init 4
kill enigma
init 3

Ralf

twol
02-06-20, 11:59
Hi,
I still miss the old behavior of init 4 which simply killed E2. I can do the same with kill -9 id-of-enigma2. killall enigma2 does not work I think. Is there a way to put this in a shell script? I can look with PS-A | grep enigma2 but how do I get the id extracted?

I want a script which looks like that:
init 4
kill enigma
init 3

Ralf
I think killall -9 enigma2 works fine.... has done for me in past.

birdman
02-06-20, 14:14
Hi,
I still miss the old behavior of init 4 which simply killed E2.Still works for me:
[et8000]: ps -ef | grep enigma2
root 828 1 0 14:09 ? 00:00:00 /bin/sh /usr/bin/enigma2.sh
root 839 828 19 14:09 ? 00:00:18 /usr/bin/enigma2
root 947 896 0 14:11 pts/0 00:00:00 grep enigma2
[et8000]: init 4
[et8000]: ps -ef | grep enigma2
root 956 896 0 14:11 pts/0 00:00:00 grep enigma2

(And it still works on a Kubuntu 2.0.4 system to stop the GUI, even though it doesn't use SYSVInit but rather systemd).

Trial
02-06-20, 15:19
Hi,
I did not test killall -9 enigma2. I think I only tried killall enigma2 then it complained about missing id. I check later.

Ralf

Ev0
02-06-20, 18:26
Try init 2

birdman
02-06-20, 22:16
I can do the same with kill -9 id-of-enigma2.Sending -9 as a signal is a bad idea.
It kills the process dead, rather than letting it shutdown (and save things that it normally leaves until shutdown to update).
-TERM (the default) would be better.

Trial
03-06-20, 07:29
Hi,
first of all killall -9 seems to work. I will also try init 2.

@birdman,
I know that it is not the bad idea but I have sometimes the case with endless spinner when I do something in the internet and init 4, init 3 cannot cure the problem. Donīt tell me that you havenīt had this problem in the last years after the changed behavior. It is only an emergency tool for me. Init 4 and reboot is not better in this situation.

Ralf

birdman
03-06-20, 12:53
..but I have sometimes the case with endless spinner when I do something in the internet and init 4, init 3 cannot cure the problem. Donīt tell me that you havenīt had this problem in the last years after the changed behavior.Not sure that init 4 would ever have stopped an endless spinner.
And I don't know of any particular behaviour change.

I was just saying that you should try a kill -TERM before resorting to a kill -KILL.

Init 4 and reboot is not better in this situation.If you're going to reboot then the init 4 is superfluous.

Trial
03-06-20, 14:31
Hi birdman,
the behavior was changed 4-5-6-7 years ago. I do not know exactly anymore.

Ralf

abu baniaz
03-06-20, 16:01
Trial is right, it changed to allow a graceful shut down to allow processes to complete.

"init 4" then "init 6" still works for a reboot if init 4/3 does not

birdman
03-06-20, 18:05
Trial is right, it changed to allow a graceful shut down to allow processes to complete.reboot would try to do that.
And init 4 should stop enigma2 if it can, as that only runs in level 3, but leave the system up.

Huevos
05-06-20, 22:22
reboot would try to do that.
And init 4 should stop enigma2 if it can, as that only runs in level 3, but leave the system up.Yes, but if enigma freezes or there is an endless spinner "init 4" will not force enigma to close. Previously "init 4" just killed the enigma process without any respect to properly saving settings, etc.

birdman
06-06-20, 02:51
Yes, but if enigma freezes or there is an endless spinner "init 4" will not force enigma to close. Previously "init 4" just killed the enigma process without any respect to properly saving settings, etc.Possibly. But init 4 just instructs the init process to move to run level 4.
This could be a change to init, or could be a change to enigma2 to ignore whatever signals init sends to tell it to stop.

Either way, an endless spinner is a bug in enigma2, so any init difference is a secondary concern.

Huevos
06-06-20, 11:22
Either way, an endless spinner is a bug in enigma2, so any init difference is a secondary concern.Gordon, I think you are missing the point. Yes, the problem is a bug causes the endless spinner. And, yes, Enigma should be closed down properly. But this wasn't always the case. The old code just halted Enigma without any respect for a proper shutdown. This meant it was easy to break out of an Enigma lock-up without needing to reboot the box.

Also, this "proper shutdown" means it is impossible for the Enigma process or plugins, etc, to overwrite system files and then call an Enigma restart without the desired changes being overwritten by the shutdown process. This was a big problem with restoring certain complicated tuner configs until Twol made changes to the restore process (which now just kills Enigma).

Trial
06-06-20, 18:40
Hi,
you are all right. But as Huevos said no code is really perfect. As I said I mostly have the problem with streaming.

My problem seems solved. killall -9 enigma2 seems to work. I write some scripts:



#!/bin/sh
/sbin/init 4
/usr/bin/killall -9 enigma2
/sbin/init 3
sleep 40s
wget http://127.0.0.1/web/powerstate?newstate=4


and while I am there also



#!/bin/sh
/sbin/init 4
cp -rf /etc /media/autofs/Backup/Enigma2/$HOSTNAME
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
opkg update
echo "Upgrade\r" > /media/autofs/Backup/Enigma2/$HOSTNAME/upgrade.txt
date >> /media/autofs/Backup/Enigma2/$HOSTNAME/upgrade.txt
opkg -V1 upgrade >> /media/autofs/Backup/Enigma2/$HOSTNAME/upgrade.txt
/sbin/reboot


I call this scripts with ssh and put these commands on a button of my Neeo remote. Now upgrade and restart is only a push button away:-)

Ralf

birdman
06-06-20, 18:58
The old code just halted Enigma without any respect for a proper shutdown.What old code did this?
init should stop a process by sending it a signal. I can't find which, but I'd expect it to be TERM.
If enigma2 used to just die when sent this than would have been a problem.
If you want to be able to shut down enigma2 quickly without updating config files then the way to achieve that is to define a specific signal that does that when sent. Such as HUP.

Trial
06-06-20, 20:10
Hi,
may be before you joined this board.

Ralf

Huevos
06-06-20, 20:48
What old code did this?Not sure how long ago. At least 5 years. Code was by Betacentauri.

Problem Tony ViXed was...

Restore a back-up... that writes "/etc/enigma2/settings"... then enigma is shut down... that shutdown writes to the settings file. That was breaking certain complicated tuner configs. Even though before the shutdown the new settings file was loaded into enigma there was some bug in the reload, that has never been found, that the new tuner config from the restore was not properly loaded into enigma... so the write back to the settings file lost some of the data. I think now after a backup restore we just kill the enigma process.

Huevos
06-06-20, 21:24
What old code did this?
init should stop a process by sending it a signal. I can't find which, but I'd expect it to be TERM.
If enigma2 used to just die when sent this than would have been a problem.
If you want to be able to shut down enigma2 quickly without updating config files then the way to achieve that is to define a specific signal that does that when sent. Such as HUP.Here is the commit...
https://github.com/OpenViX/enigma2/commit/7b9ad81ba22e41fcbe29305aeb7598b7eddf49fe#diff-06656248397287332f050cd51868efa6

birdman
07-06-20, 03:37
Not sure how long ago. At least 5 years. Code was by Betacentauri.

Problem Tony ViXed was...

Restore a back-up... that writes "/etc/enigma2/settings"... then enigma is shut down... that shutdown writes to the settings file.I reckon the problem with that is the way the code runs.
How I would expect a restore to work is:


write a script to do the restore
stop enigma2
run the script
start enigma2 (which will be part of the restore script).


Alternatively, just have a global flag called no_settings_save_on_shutdown, set it and act on it....
Relying on behaviour from an unrelated activity is usually fraught with problems.

Huevos
07-06-20, 18:04
I reckon the problem with that is the way the code runs.
How I would expect a restore to work is:


write a script to do the restore
stop enigma2
run the script
start enigma2 (which will be part of the restore script).


Alternatively, just have a global flag called no_settings_save_on_shutdown, set it and act on it....
Relying on behaviour from an unrelated activity is usually fraught with problems.I like idea 2. Can we look at where that is possible?

With idea 1, if we stop enigma, how do we start the script?

birdman
07-06-20, 19:14
With idea 1, if we stop enigma, how do we start the script?enigma2 (the binary) is run from enigma2.sh (the script) and the script checks the exit code.
It already checks for a half-dozen or so cases.