You are not logged in.

#1 2016-06-01 08:52:52

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Machine hangs if powered off without quitting some processes

I am on XFCE. If I power off the machine (with the poweroff command or with power button, both of which will use systemd), the machine hangs if I have not properly quitted  some software. It does appears if chromium is still running when I power off the machine (strangely, it does not appears with every software). I wonder what's the real cause of this and if a solution exists. I would like systemd to kill all jobs, possibly forcefully and poweroff the machine like the old sysv did. I do not count how many times I have used the magic SYSRQ trick to power off my machine.

Last edited by olive (2016-06-01 12:22:43)

Offline

#2 2016-06-01 09:14:09

Ropid
Member
Registered: 2015-03-09
Posts: 1,065

Re: Machine hangs if powered off without quitting some processes

How long did you wait when the machine appears to hang? I think with default settings, systemd will wait 90 seconds before it kills processes. Maybe you never waited that long and the machine isn't really hanging?

Last edited by Ropid (2016-06-01 09:14:43)

Offline

#3 2016-06-01 09:20:13

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Machine hangs if powered off without quitting some processes

@Ropid I didn't wait that long, that's true. But honestly I don't want to wait 90 sec to power off the machine. Is there any possibility to lower the 90 sec to a lower value (a few seconds only); I think the old sysv waited only 5 sec (It was coded in a shell script if I remember correctly).

Offline

#4 2016-06-01 10:06:02

Ropid
Member
Registered: 2015-03-09
Posts: 1,065

Re: Machine hangs if powered off without quitting some processes

Yes, those 90 seconds are just the default. You can configure it globally in /etc/systemd/system.conf, or if you find out what exactly is hanging you can try to change just that particular unit.

For the global setting, create a folder /etc/systemd/system.conf.d/ and then a file in there like "timeout.conf". Put for example this here in it:

[Manager]
DefaultTimeoutStartSec=30s
DefaultTimeoutStopSec=30s

If you do "systemctl daemon-reload" afterwards, the changes get applied immediately (without reboot needed).

To change just one service instead of everything, you can do this:

$ sudo systemctl edit servicename

Then type this here in the editor that comes up:

[Service]
TimeoutStopSec=5s

Last edited by Ropid (2016-06-01 10:06:59)

Offline

#5 2016-06-01 10:41:04

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Machine hangs if powered off without quitting some processes

@Ropid Thanks a lot! Problem solved!

Offline

#6 2016-06-01 10:49:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,738
Website

Re: Machine hangs if powered off without quitting some processes

That's really not a good solution.  Setting a very low timeout could disallow the normal shutdown of important programs.  See this thread for better options.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2016-06-01 12:22:31

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Machine hangs if powered off without quitting some processes

@Trilby. You are right; there is still a bug somewhere. When I logout, all processes terminates gently (I have logged as root from the console to check that nothing remains). But when I poweroff, reboot (even within the graphical interface), this is apparently not the case. Every sane way to poweroff the machine should obviously terminates the session before; so this is buggy. I find the session concept under systemd somewhat confusing. systemd manage sessions but also the DE and the login manager; I do not really understand what is responsible for what exactly. I would be interested in a "proper" solution; a solution that implies that the session terminates properly before shutdown. Not just hacking the system with another script that kill every windows. I do not know if there is a bug report somewhere for that and because I am totally confused about the responsibility of each component I am unable to fill a proper bug report at the right place.   

I remove for now the Solved keyword since it was not properly solved.

Offline

#8 2016-06-01 14:41:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,738
Website

Re: Machine hangs if powered off without quitting some processes

There is no bug report as there is no one to report it to.  Please read the thread I linked to, specifically post #21.

This is a problem, but it cannot really be called a bug in any specific software as all software can perform to specifications and still result in this problem.  The bug is in the "specifications", but as these are more emergent de-facto and/or consensus based policies, there is no where to appeal a change.

Just set your system up to deal with programs on their own terms.  Some programs have signal handers, others have X11 event handlers.  Some have both of course, and this is really nice, but not having both is really not a bug.  So when you want to shut down a graphical session, send both the signals and the events and everything will be fine.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2016-06-01 15:49:11

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Machine hangs if powered off without quitting some processes

@Triby I have read the thread. But there is still something I don't get. If I logout, all programs (chromium, etc.) terminate properly with no noticeable delay. So the windows manager/DE (or is it systemd?) is able to terminate the programs properly when I logout. i don't know exactly what happen but I see no programs that does not respond to the signals sent.

Now, when I click power off this does not happen. One could reasonably expect that the Windows manager/DE first perform a logout and then power off when you click power off. This this last thing that I call "buggy". Now I am somewhat confused about who exactly logout and what happens when you logout.

Last edited by olive (2016-06-01 15:56:26)

Offline

#10 2016-06-01 16:38:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,738
Website

Re: Machine hangs if powered off without quitting some processes

So following from post 21 in the other thread, you've ruled out numbers 1 and 2.  You say you "click power off", where do you click this?  This will differentiate between numbers 3 and 4 in my list.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2016-06-01 16:53:33

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Machine hangs if powered off without quitting some processes

I have tried in XFCE the "Shut down" (not poweroff as I wrongly said) available from the GUI (Applications -> Logout -> Shut down). But I can as well type poweroff or "systemctl poweroff" in a terminal with the same effect. Curiously it is not 100% reproducible, sometimes it works for no apparent reason. But when I logout I never have a problem. So I assume it is a bug in XFCE but other DE seems affected too. Moreover I am confused because systemd and the login manager also have a notion of "session", so it may be a problem there.

Last edited by olive (2016-06-01 16:54:00)

Offline

#12 2016-06-01 17:26:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,738
Website

Re: Machine hangs if powered off without quitting some processes

olive wrote:

I have tried in XFCE the "Shut down" (not poweroff as I wrongly said) available from the GUI (Applications -> Logout -> Shut down). But I can as well type poweroff or "systemctl poweroff" in a terminal with the same effect.

It might seem like the same effect, but these are for completely different reasons.  If you use an XFCE function to shut down and it does not send an X11 event to all child windows to close, then this is a bug with XFCE (this is #3 in my post in the other thread).  You can use the xkillall type of program/script to work around this.  If you use "systemctl poweroff" this is probably not a bug in the WM/DE, but you could submit a feature request to the dev team of that WM/DE to handle a sigterm (this is #4 in my post in the other thread).  You can also use the xkillall type of program to work around this.

It is not at all surprising that this doesn't happen 100% of the time.  Client programs failing to get a signal/event-message to shutdown is only one of the necessary conditions for this to occur.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB