process waits forever spawn_opt/5

Rickard Green rickard@REDACTED
Wed Jun 16 17:03:26 CEST 2021


On Wed, Jun 16, 2021 at 9:15 AM Vyacheslav Levytskyy <v.levytskyy@REDACTED>
wrote:


> The function doesn't interact with the gen_server that calls spawn/4,
> although I'd expect spawn/4 to run a process and return immediately
> anyway, am I wrong?
>
>
All spawn operations except for spawn_request() (introduced in OTP 23) are
synchronous and block until the new process has been created and the caller
of the BIF has received the process identifier of the newly created process
or an error is detected. In case the connection between the nodes stalls
the caller will be blocked until the network ticker takes down the
connection (default 60 seconds).


> >>
> >> I'm surprised to see my gen_server process hanging forever when
> >> executing spawn/4 call. Process info shows spawn_opt/5 as a current
> >> function and status is waiting:
> >>
> >>   > process_info(P).
> >> [{current_function,{erlang,spawn_opt,5}},
> >>    {status,waiting},
> >>    {message_queue_len,13},
> >>    {trap_exit,false},
> >>    {priority,normal},
> >>    ...]
> >>
>

Would have been interessting to know what process_info(P, messages) had
returned. In the distributed case spawn_opt() is waiting for a message on
the format: {spawn_reply, Ref, ok|error, Pid|Error}

What type of node is the node that you are trying to spawn the new process
on? Ordinary Erlang node, C-node, ...? OTP release of that node?

Regards,
Rickard
-- 
Rickard Green, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210616/62dbdcad/attachment.htm>


More information about the erlang-questions mailing list