Shutting down too fast?
Everytime I shutdown/reboot my computer, my Chromium dies (asks me if I want to restore the last session) so I've been trying to set up a shutdown script which gracefully kills it instead. I've read some guides online with the usual Before=shutdown.target etc but I can't get it to work. Can someone please post a service file which works for them?
My current theory is that Arch shuts down "too fast". I have used Linux Desktops before, and although their shutdown was way faster than Windows', it wasn't quite as instantaneous as it is now.
About this post
- Posted
- Archived
- Score
- 32 · 90% up
- Kind
- Text
- ID
- vy88ja
22 comments
If I shutdown without closing browsers on Fedora, I get the same restore question on startup. So it's not just Arch, or nothing to do with speed. Probably browsers just handling the quit signal poorly (don't remember which signal that is exactly).
Maybe related to the "are you sure you want to close X tabs" popup? The OS tells the browser to quit, and the browsers asks about closing tabs, and eventually gets killed forcefully because the first graceful signal did not work?
Chromium doesn't ask, it just closes. But if I shutdown gedit for example, it does ask me if I would like to save any open files before closing. But even then, I can gracefully kill Chromium with
pkill -2, I just haven't found a way to run that before shutdown yet.You can alias the shutdown command to do so, unless you are using physician buttons or some menu.
I just remembered that there's an AUR package called
chrome-shutdown-hookthat closes Chrome/Chromium gracefully on logout, but judging from the comments this is not an issue anymore. Try resetting your profile and disabling extensions as per the comments: https://aur.archlinux.org/packages/chrome-shutdown-hookIf you want to do the systemd service, it should work by having
ExecStartdo something likesleep inf, andExecStopdoing the actual quitting of Chromium.Okay, so turns out that the systemd service did work; I just must've gotten super unlucky. After some testing I've concluded that it doesn't always work, and that
SIGTERMworks better thanSIGINT. So this is all you need (works for logout, shutdown and reboot):it works well from terminal, but from gnome-shell, it doesn't seem to be working for me.
this is same log as when I start service manually without chromium running.
Deleted before we saved it.
Yeah but when you kill the application gracefully, it doesn't ask you to restore the last session. It just loads it.
Deleted before we saved it.
I have opposite problem. does anyone know how I can ask chrome to restore the last session automatically on start? I don't want to click on yes every time. Yes, I have finally dedicated some ram for chromium.
Yeah, use my shutdown service. That gets run before the actual shutdown happens, and shuts down Chromium "softly". That way it doesn't even ask you to restore the session, it just does so automatically.
omg, didn't realize thanks earlier. Thanks OP OP. Either way - if user wants a restored chrome or a clean chrome, it is a good behavior. imho sigterm should be how shutdown is performed. afaik it waits for like 60 seconds or more for systemd services to gracefully stop, but applications are thrashed instantly.
on more digging I think this is the issue: https://unix.stackexchange.com/questions/122590/graceful-shutdown-in-archlinux .
check TimeoutStopSec here: https://www.freedesktop.org/software/systemd/man/systemd.service.html
Systemd does not give gdm much time, but I wonder even if it did. what signal gdm would send anyway.
More I think about it, I feel from applications view, existing shut down is like just pulling the power cable. well, atleast systemd stuff like file systems exit properly. so it is not that bad. user apps are pretty much fucked.
another thing, it might not be systemd completely at fault here. it is the window manager (gnome/x11 in my case) that finally tells systemd to start shutdown systemd's services when we call shutdown). but the behavior must be coherent from both shell and ui.
This is a feature, not a bug. Why do you think it's a problem?
It would appear to be a bug. I've done no special configuration for Chromium or shutting down, but Chromium stops gracefully and does not ask to restore tabs if I shut down my PC. I can confirm that I've not disabled that feature in Chromium and it is working properly. If I
pkill -9 chromiumor kill the power to my PC then it will prompt me to restore tabs.Either I have a bug because Chromium stops gracefully before shutting down, or OP has a bug because it doesn't ¯\_(ツ)_/¯
Hm, I just assumed that all Chromiums are the same, but maybe it's because I use
ungoogled-chromium? Anyway, it works with the shutdown script now, so I don't care ;)crash bad
Why do you think it's crashing?