0

I have a parent process and set of child process associated with it.

If I run system("reboot") in parent process,

  1. What signal will be sent to the child process?
  2. Are we able to handle those signals?
Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
user1762571
  • 1,888
  • 7
  • 28
  • 47
  • possible duplicate of [how to detect Linux shutdown/reboot\[solved\]](http://stackoverflow.com/questions/22009705/how-to-detect-linux-shutdown-rebootsolved) – Kevin Panko Jul 07 '14 at 20:13

2 Answers2

1
  1. Possibly SIGTERM or SIGKILL, which are sent by init as the system is rebooted.

  2. Sort of, but not really. You can trap SIGTERM, but SIGKILL is always fatal, and the system is rebooting anyway. Your process is inevitably going to die when that happens.

1

On a system reboot init sends SIGTERM to all the child process and waits for it to terminate. It again sends SIGTERM after some time if the child did not terminate and finally sends a SIGKILL which cannot be blocked to kill the child.

Vipul
  • 566
  • 5
  • 29