Erlang / Erlang Basics Interview questions
Explain the lifecycle of a supervised process?
A supervised worker follows a well-defined path from start to eventual restart or shutdown, orchestrated entirely by its supervisor.
stateDiagram-v2
[*] --> Starting: supervisor calls start_link
Starting --> Running: init/1 returns {ok, State}
Running --> Crashed: unhandled error / exit
Running --> Terminating: normal shutdown requested
Crashed --> Starting: supervisor restarts per strategy
Crashed --> GivingUp: restart intensity exceeded
Terminating --> [*]
GivingUp --> [*]: supervisor itself terminates/escalates
On start_link, the supervisor blocks until init/1 replies (so a failed startup is
caught immediately, not silently). Once running, the process handles calls/casts/info messages until it either
shuts down normally, or crashes. A crash triggers the configured restart strategy
(one_for_one/one_for_all/rest_for_one); if crashes happen faster than the
configured intensity/period allows, the supervisor gives up and escalates the failure to its own parent instead
of looping forever.
More Related questions...