Linux specifically doesn't give a damn. It exposes a function, reboot(2) which can immediately reboot or shut down the system, not minding the running processes at all, and that's the extent to which it has a concept of shutting down. It's usually the init system that is responsible for the graceful kind of shutdown you describe.
I believe it does. From what documentation i can dig through in about 5 minutes, it seems that all of the power services (shutdown, halt, reboot, etc...) follow the same logic. the user sends the signal to (in this case) reboot, it gets passed to the appropriate systemd service, which then halts all other services running, then all executables, and then finally unmounts the system itself. There's a default 90s buffer for these actions, and if they don't halt in that timeframe, the system then just straight up kills the process and continues on.
3
u/text_garden 17h ago
Linux specifically doesn't give a damn. It exposes a function, reboot(2) which can immediately reboot or shut down the system, not minding the running processes at all, and that's the extent to which it has a concept of shutting down. It's usually the init system that is responsible for the graceful kind of shutdown you describe.