Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants