link to hibernated process
by
by@REDACTED
Mon Apr 27 01:40:16 CEST 2020
Explicitly call erlang:exit(error) will make this example works as expected: both 4> and 5> returns undefined.
3> spawn(fun() -> spawn_link(C), io:format("parent: ~p ~p~n", [self(), F()]), erlang:exit(error) end).
Cheers,
Yao
> 在 2020年4月27日,00:26,Dinislam Salikhov <Dinislam.Salikhov@REDACTED> 写道:
>
> Hello,
>
> There is a link from a process to another process which may come into hibernate state. I expect that when the former process terminates, the latter one does as well, but it doesn't happen:
>
> Erlang/OTP 21 [erts-10.3.5.9] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
>
> Eshell V10.3.5.9 (abort with ^G)
> 1> F = fun() -> {links,L} = process_info(self(), links), L end.
> #Fun<erl_eval.20.128620087>
> 2> C = fun() -> io:format("child: ~p ~p~n", [self(),F()]), erlang:hibernate(erlang,exit,[ok]) end.
> #Fun<erl_eval.20.128620087>
> 3> spawn(fun() -> spawn_link(C), io:format("parent: ~p ~p~n", [self(), F()]) end).
> parent: <0.82.0> [<0.83.0>]
> child: <0.83.0> [<0.82.0>]
> <0.82.0>
> 4> process_info(pid(0,82,0),links). % dead parent, as expected
> undefined
> 5> process_info(pid(0,83,0),links). % alive child, unexpected
> {links,[]}
>
> Is it a bug? Or do I miss anything?
>
> Dinislam Salikhov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200427/caecd6d8/attachment.htm>
More information about the erlang-questions
mailing list