You are right! A simpler way (for me) is informing the parent that the child is started/ready:
def sample do
lab_pid = self()
spawn_link(fn ->
parent_pid = self()
spawn_link(fn ->
Process.flag(:trap_exit, true)
send(parent_pid, :started)
receive do
{:EXIT, _pid, :normal} ->
send(lab_pid, :done)
end
end)
# :timer.sleep(100)
receive do
_ -> 0
end
end)
receive do
msg -> msg
end
end






















