As I know, we can send a signal SIGTERM to a process by pressing ctrl+c or by using pkill -f processName.
Also, when we reboot or shutdown, the kernel will send SIGTERM to each process too.
So I'm asking if we could distinguish these two cases? (as they are all SIGTERM, we can't distinguish them by the signal)
Maybe the kernel provides us some kind of API? such as bool isRebooting() or bool isShutdown()?
SIGTERM, the shutdown procedure does. What init system and/or service manager are you using? – Stephen Kitt Dec 26 '18 at 12:39