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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.