The way running processed handled when shutting down/rebooting

Is there a difference in the way running processes are handled among:

shutdown now
shutdown -r now
reboot
(CLI without -f)
Power off
Restart
(gui desktop)

?

This could help.
The GUI is likely calling the CLI commands in the background, so expect the same effect.

About signals sent during shutdown:

I recommend you before asking try to research a bit, if you couldn’t find the answer then the people here can help.

I actually did research and did find this information. But the actual situation doesn’t seem to match the info about termination signaling. Therefore I felt the need to ask it here.

Here is what I’m talking about:
Even if you have an unsaved document in libreoffice, you can shut down Fedora in 3 seconds, immediately killing the program without any warnings or a chance to save.
You may say Libreoffice is to blame here but gnome’s own text editor (with the package name gnome-text-editor) also behaves exactly the same.
So it seems odd to me that fedora doesn’t care and/or programs don’t listen.

Idk about GNOME, but on KDE when I shutdown, apps ask me if I want to save open files, so it definitely isn’t a sigkill.

1 Like

This is not a Fedora thing as much as it is Linux, LInux Desktop Environments and applications all do things a little differently.

These commands are all handled by systemd, so unless there is something inhbiting the command it will be executed.
IE …
From a terminal
systemd-inhibit gnome-text-editor
Then open another terminal window and type shutdown or systemctl poweroff

If everything is working as it should, it shoudln’t shut down and you will recieve a notification as to why.

Possibly oversimplifying it a bit when you :
If a user is allowed to execute a command from the command line, unless there are checks built into that command that can prevent it’s execution it is run. IE the user is allow to do that and meant to.

For the GUI shutdown, it’s going to depend on the Desktop Environment and the application you’re using. As long as the functionality exists and they communicate you should be prompted.

As an example using Gnome 43:
Opened libre office writer and started typing a document and then selected power off from the menu.
I wasn’t promped, which corresponds with this bug https://bugs.documentfoundation.org/show_bug.cgi?id=142176

I did the same thing with gnome-text-editor and I was presented a prompt that indicated I had an unsaved document.

I have to correct myself here: Apparently the shutdown command is not behaving like the GUI shutdown. To try it out I opened the Kate text editor, whote some text and ran shutdown +0, it immediatly shutdown without asking and the text was lost. I booted back and this time I used the GUI shutdown, which gave me the normal prompt for unsaved data, I dismissed the prompt which caused the shutdown to cancel.

I had to check the reason of this behavior, so I sent a sigterm to kate using kill -15 $(pgrep kate), which as expected gave the prompt, even sigint gave the prompt. So did the shutdown command actually kill all processes, or some other process (plasmashell?) when received sigterm ended everyone else?

Edit: more info:
It appears that the shutdown command is sending sigterm to all processes, but the difference here is that the X server (yes I use X11) is being terminated early, which is why the prompt didn’t even appear, judging by the logs:

Nov 11 17:31:45 hostname sddm[1460]: Signal received: SIGTERM
Nov 11 17:31:45 hostname kded5[1942]: The X11 connection broke (error 1). Did the X11 server die?
Nov 11 17:31:45 hostname ksmserver[1939]: The X11 connection broke (error 1). Did the X11 server die?
Nov 11 17:31:45 hostname systemd[1]: avahi-daemon.service: Deactivated successfully.
Nov 11 17:31:45 hostname kwin_x11[1945]: The X11 connection broke (error 1). Did the X11 server die?

So X11 probably died before the DE itself.

Edit2: Can confirm, I sent sigterm to x11 and I was dumped at the login screen without asking for any confirmation for poor kate.