0

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()?

3
  • 2
    No, the kernel doesn’t send SIGTERM, the shutdown procedure does. What init system and/or service manager are you using? Dec 26, 2018 at 12:39
  • "shutdown" is a userspace concept, not a kernel one. The init system (sysvinit, systemd, upstart,....) will be doing all this work. Dec 26, 2018 at 13:17
  • what unix system sends a TERM signal when you mash control+c? more typical is an INT signal...
    – thrig
    Dec 26, 2018 at 15:30

0

You must log in to answer this question.

Browse other questions tagged .