Supervisors may sound magical, but there are two simple, practical mechanisms behind their magic: linking processes and trapping exits. We’re going to see how they work together to make supervisors work.
The key to process supervision is for one process to be able to link to other processes and know when those other processes crash. Beyond that, the supervising process needs to be able to keep running if it gets crash notifications from processes it’s linked to.
When one process in a group of linked processes crashes, it sends a special kind of message called an exit signal to all the other processes it’s linked to. Any process that receives an exit signal will also exit and send an exit signal to all the other processes that ...