OpenELEC/OpenELEC.tv — pull request #1762 by stefansaraev (2013-01-15 20:45:32+00:00)
Title: safe shutdown / reboot

on shutdown / reboot the TERM signal must be sent to all processes.
we need this because some daemons do not save their config / data unless TERM signal is sent, see #297 #1756 #1606

to achieve this, we need a true init system or:
1. busybox compiled with killall5 applet
2. kill sshd early because if connman gets killed first (some) active ssh sessions may freeze. that's why I left "killall sshd" intact.
3. invoke killall -15 then:
- check for processes which are still alive,
- wait some time for them to finish. currently 5 seconds, we may increase / decrease this but it doesn't matter much. shutdown time is not as important as boot-up time
- if a process does not honor SIGTERM and is unable to exit cleanly in 5 seconds it should burn in hell
4. shutdown / reboot
5. profit :)