This repository was archived by the owner on Jun 10, 2024. It is now read-only.
This repository was archived by the owner on Jun 10, 2024. It is now read-only.
Parent process for spawn_link/1 exits with {exit, ChildReason} instead of just ChildReason when monitored #546
Open
Description
init.erl
-module(init).
-export([start/0]).
-import(erlang, [display/1]).
-import(lumen, [log_exit/1]).
start() ->
lumen:log_exit(false),
{ParentPid, ParentMonitorReference} = spawn_monitor(fun () ->
ChildPid = spawn_link(fun () ->
wait_to_shutdown(),
exit(shutdown)
end),
ChildMonitorRef = monitor(process, ChildPid),
shutdown(ChildPid),
receive
{'DOWN', ChildMonitorRef, process, _, Info} ->
display({child, exited, Info})
after
10 ->
display({child, alive, is_process_alive(ChildPid)})
end,
ok
end),
receive
{'DOWN', ParentMonitorReference, process, _, Info} ->
display({parent, Info})
after
100 ->
display({parent, alive, is_process_alive(ParentPid)})
end,
ok.
shutdown(Pid) ->
Pid ! shutdown.
wait_to_shutdown() ->
receive
shutdown -> ok
end.
Actual Output
{parent, {exit, shutdown}}
Expected Output
{parent, shutdown}