From the example given here, Erlang and process_flag(trap_exit, true)
-module(play).
-compile(export_all).
start() ->
process_flag(trap_exit, true),
spawn_link(?MODULE, inverse, [***0***]),
loop().
loop() ->
receive
Msg -> io:format("~p~n", [Msg])
end,
loop().
inverse(N) -> 1/N.
If I run it as,
A = spawn(play, start, []).
The spawned process <0.40.0> dies as it is suppose to but the main process (A <0.39.0>) which spawned it doesn't die.
{'EXIT',<0.40.0>,{badarith,[{play,inverse,1,[{file,"play.erl"},{line,15}]}]}}
<0.39.0>
i().
....
....
<0.39.0> play:start/0 233 19 0
play:loop/0 1
A does get an exit signal (not an exit message since A is not trapping exit) then why doesn't it exit?
spawn_link(erlang, div, [1, 0])kills the shell process that spawned it. It's possible that in later (or earlier) versions they added exit trapping to shell processes. - Soup d'Campbells