Skip to content
This repository has been 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
KronicDeth opened this issue Aug 23, 2020 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@KronicDeth
Copy link
Collaborator

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}
@KronicDeth KronicDeth added the bug Something isn't working label Aug 23, 2020
@KronicDeth KronicDeth added this to the ElixirConf 2020 milestone Aug 23, 2020
@KronicDeth KronicDeth self-assigned this Aug 23, 2020
KronicDeth added a commit that referenced this issue Aug 24, 2020
If the `reason` passed to `__lumen_builtin_error` is a 2-tuple of `{Class, Reason}` where `Class` is `error` or `exit`, exit the process with just `Reason`.
KronicDeth added a commit that referenced this issue Aug 24, 2020
If the `reason` passed to `__lumen_builtin_error` is a 2-tuple of `{Class, Reason}` where `Class` is `error` or `exit`, exit the process with just `Reason`.
KronicDeth added a commit that referenced this issue Aug 24, 2020
If the `reason` passed to `__lumen_builtin_error` is a 2-tuple of `{Class, Reason}` where `Class` is `error` or `exit`, exit the process with just `Reason`.
KronicDeth added a commit that referenced this issue Aug 26, 2020
If the `reason` passed to `__lumen_builtin_error` is a 2-tuple of `{Class, Reason}` where `Class` is `error` or `exit`, exit the process with just `Reason`.
KronicDeth added a commit that referenced this issue Aug 26, 2020
If the `reason` passed to `__lumen_builtin_error` is a 2-tuple of `{Class, Reason}` where `Class` is `error` or `exit`, exit the process with just `Reason`.
@KronicDeth KronicDeth modified the milestones: ElixirConf 2020, In 2020 Sep 3, 2020
@bcardarella bcardarella assigned bitwalker and unassigned KronicDeth Dec 9, 2020
@bcardarella bcardarella modified the milestones: In 2020, In 2021 Dec 9, 2020
@bitwalker bitwalker modified the milestones: In 2021, 2023 Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants