I'm trying to get a graceful shutdown/reboot in ArchLinux with GNOME Shell. Now, when I ask for shut-down, it immediately shuts down without giving open programs time to gracefully close / save open files. As a result, whenever I restart Chrome (for example) it tells me that the session was not closed correctly etc.
By reading on the web I learnt that systemd while shutting down processes, it first send a SIGTERM
followed by SIGKILL
if the process does not close withing a given timeout. However I notice that on my system SIGKILL
is sent immediately after SIGTERM
and I guess this is the cause of a non graceful programs termination.
I've found some documentation which (if I read it correctly) states that timeout before sending SIGKILL
can be set by TimeoutStopSec=
option. Also sending SIGKILL
could also be disabled by SendSIGKILL=
option. But I cannot find where to configure those options... is there a systemd shutdown / reboot configurations file where I can set those options?
EDIT:
I did some test and I discovered two interesting things:
- If I manually close chrome like this
killall -SIGTERM chrome
, it will not complain that is has not been closed correctly next time I start it again. If I close it like this insteadkillall -SIGKILL chrome
, it will complain. This tells me that chrome is handling SIGTERM correctly. - Looking at the output of my shutdown procedure, systemd prints
Sending SIGTERM...
immediately followed bySending SIGKILL...
According to comment below, systemd is handling its processes only. So in my case GDM. This tells me that the issue could be:
- either GDM not closing it's child processes (e.g. Chrome) correctly (i.e. by sending SIGTERM to them)
- or systemd is sending GDM a SIGKILL message to early not giving it the time to correctly close its children.
Is there a way to check/configure how actually GDM closes its children?
systemd's
control -systemd
ispid 1
- but Chrome execs out of its wrapper script in a subshell and invokes child processes afterward. Still, it will do what it needs to kill itszygotes
so long as your system is properly configured. Are you using one of those temp-space solutions for chrome that you'll find recommended in the Arch wiki?gnome-session
.