System enters "shutdown mode" too early

Description

When shutting down the system, the registrar does not allow to start any new application anymore. This is understandable, but the way it does it now can easily get annoying: if an application needs user interaction to be quit (like manually deciding wether or not to save an open document), it doesn't make any sense to forbid the user to open new applications.

The system should only prevent new apps from being started after all user apps has been successfully quit.

Change History
(29)

The code responsible for this seems to be src/servers/registrar/ShutdownProcess.cpp.

There is an USER_APP_TERMINATION_PHASE, in which it should be allowed to start new apps. The shutdown process should try to kill all applications one by one (possibly with "the document has unsaved changes" alerts interrupting it - try it with an unsaved file in StyledEdit for example). After all apps have been terminated, we will enter SYSTEM_APP_TERMINATION_PHASE. In this phase, all system applications (servers, etc) will be terminated. The user should not be allowed to start new apps.

I don't know the code further so I will let you study how this works. Let us know if you have more specific questions.

Yes, the git repo is the same. The instructions at "submitting patches" should get you started with submitting, but this is all very new so maybe the instructions are not clear. Let me know what you did and the error you get and I'll see how to fix it and how to improve the document.

Shutting down the system has become a lot slower since I updated to the latest nightly. Tested on a Thinkpad X220 and X61s with the same results. The time it takes from pushing "shut down" in the menu until the system is dead is a good while longer, pretty much 3 to 4 times longer. It's still measured in seconds, but it's really noticable.

Yes, of course _QuitApps(fSystemApps, true); will quit the system apps, including the logger. In case you need to log things after that point, you could create a file yourself (using BFile or classical fopen, fprint) and log there.

Hello with your changes I know that wpa_supplicant wont shutdown and so Haiku wont shutdown if I dont kill application wpa_supplicant... relevant to ticket I added some time ago: Haiku wont shut down...
can you make wpa_supplicant to close at shutdown? Maybe you solve my bug by doing so...
thx Bruno

Yes, of course _QuitApps(fSystemApps, true); will quit the system apps, including the logger. In case you need to log things after that point, you could create a file yourself (using BFile or classical fopen, fprint) and log there.

I tried this, still there isn't any significant time that I see. Max time I see is just over a millisecond. Maybe I'm calculating the time wrong.

What I did was, after each 2-3 statement, I printed the difference in timestamps (using clock() from time.h). Is there a better method for this?

A bit of trace in the kernel lets me know that the launch_daemon keeps relaunching daemons (net_server, syslog_daemon, mount_server, package_daemon, power_daemon). It seems the launch_daemon handles this incorrectly when the system shutdowns.