Хабр Курсы для всех
РЕКЛАМА
Большая витрина: от крупнейших школ до частных авторов. Сравнивайте по цене, длительности, формату и выбирайте самый подходящий курс!
When a process is trapping exits, it will not terminate when an exit signal is received. Instead, the signal is transformed into a message {'EXIT',FromPid,Reason} which is put into the mailbox of the process just like a regular message.
An exception to the above is if the exit reason is kill, that is if exit(Pid,kill) has been called. This will unconditionally terminate the process, regardless of if it is trapping exit signals or not.
Оболочка получила сигнал {'EXIT',<0.44.0>,kill}, но не завершила свою работу!
1> spawn_link(erlang, apply, [fun(Parent)-> timer:sleep(15000), io:format("finish~n", []) end, [self()]]).
<0.35.0>
finish
2> exit(spawn_link(erlang, apply, [fun(Parent)-> timer:sleep(15000), io:format("finish~n", []) end,[self()]]),kill).
** exception exit: killed
9> spawn(erlang, apply, [fun(Pair)-> process_flag(trap_exit, true), link(Pair), exit(Pair, kill), timer:sleep(1000), io:format("finish pair~n", []) end, [spawn(erlang, apply, [fun(Parent)-> process_flag(trap_exit, true), timer:sleep(15000), io:format("finish~n", []) end, [self()]])]]).
<0.52.0>
finish pair
Слежение за процессами и обработка ошибок, часть 2