FSM of the program
RUNNING
TERMINATING
KILLING
PDEATH
Send SIGTERM to process
New state = TERMINATING
TERM
TERM
PDEATH
KILL
TERM
KILL
PDEATH
Send PDEATH to main fsm
If termination IGNORE
New state = ZOMBIE
If termination EXIT
Send TERM to main fsm
New state = ZOMBIE
If termination RESPAWN
If restart delay
Arm START_TO timer
New state = RESTARTING
else
New state = RUNNING
Send SIGKILL to the process
New state = KILLING
Send PDEATH to main fsm
New state = ZOMBIE
Send PDEATH to main fsm
New state = ZOMBIE
RESTARTING
TERM
Stop the start timer
Send PDEATH to main fsm
New state = ZOMBIE
START_TO
Fork/exec the program
New state = RUNNING
ZOMBIE
END