original articles, reproduced please specify the Source: Server non-amateur research http://blog.csdn.net/erlib author Sunface
Contact e-mail: [Email protected]
It is estimated that many students will be a little confused about the various signals and capturing mechanism of link, I am drawing a form here, I share it to everyone
reason |
trapping exits (trap_exit = True ) |
not trapping exits (trap_exit = False ) |
normal |
Receives{‘EXIT‘, Pid, Normal} |
Nothing happens |
kill |
terminates with Reason killed |
terminates with Reason killed |
other |
receives {' EXIT ', Pid, other} |
Terminates with reasonOther |
If there is a A, a, two process and link to each other1. When the end of A is normal (the process is normal), B will not exit, at this time the link mechanism does not take effect2. If the end of a is killed, such as Call Exit (Pida,kill), the exit signal capture mechanism is not valid, regardless of whether B has a set trap_exit,b terminate.3. If the end of a is not normal or killed (for example, Exit Pida,reason), then B will capture the exit signal when the trap_exit is set, instead of receiving a message {' EXIT ', Pid,reason}, at which time B does not end, the user can process the end of a process according to the message received, if B is not set TRAP_EXIT,B will terminate
I hope that we can clarify these relationships, and that these relationships are very important in building systems ., I hope everyone can design a clear and well-coupled structure
[Erlang]link Process Signal explanation