link to hibernated process

Peti Gömöri gomoripeti@REDACTED
Mon Apr 27 01:22:48 CEST 2020


Hi Dinislam

If a process terminates normally, it won't cause other linked processes to
terminate, "An exit signal with reason normal is ignored."  see
http://erlang.org/doc/reference_manual/processes.html#receiving-exit-signals
This is independent of whether the receiving process is hibernated or not.
With any other exit reason your assumption would be correct that the linked
process should also terminate.
(Note that the atom 'ok' is also an abnormal termination reason)

On Sun, Apr 26, 2020 at 6:27 PM Dinislam Salikhov <
Dinislam.Salikhov@REDACTED> wrote:

> 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/ba971fa6/attachment.htm>


More information about the erlang-questions mailing list