Does the OS stop all PIDs before restarted when the user clicks restart in Ubuntu?

Quesofat asked:

I have a server written in Node.js listening to SIGTERM and SIGINT events. I’m wondering id the Ubuntu stops all PIDs (or which PIDs) it stops before restarting. So for example if my node process listens to those events and wants to gracefully shutdown but gracefully shutting down will take awhile how long do I have before the OS force kills it.

My answer:

If you choose to shutdown or reboot the system, then systemd will send your process a SIGTERM signal first. If it doesn’t react to SIGTERM within a certain amount of time, it will send SIGINT, and if it still doesn’t respond to that it will eventually send SIGKILL. I believe the times are 90 seconds and 5 minutes respectively, but I can’t find the relevant docs, it’s been quite a while since I profiled shutdown, and I don’t want to profile shutdown again right now…

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.