Hello i am running a problem and i get an error from a linked process.I do not know how to debug what went wrong in a process.
I have enabled process_flag(trap_exit,true)
but still can't figure out what is wrong.
Error
30> conc2:initFam(). <0.170.0> =ERROR REPORT==== 24-Aug-2019::07:55:03.403000 === Error in process <0.170.0> with exit value: {undef,[{conc2,brother,[],[]}]}
How can the error be read?So what is
undef
in the return tuple,and what are the two[]
in the second element of the tuple ? I can understand something happened inbrother
method but more i can't understand.
How do you debug a process in Erlang ?
-module(conc2).
-compile([debug_info]).
-export([initFam/0]).
initFam()->
Bid=spawn(?MODULE,brother,[]),
Bid.
brother()->
Sid=spawn(?MODULE,sister,[self()]),
link(Sid),
brotherLoop(Sid).
brotherLoop(Sid)->
receive
kill->Sid ! issue_kill;
Msg->[Msg|brotherLoop(Sid)]
end.
sister()->
receive
MSG ->
exit(killed_by_bro)
end.
Basically i spawn a process that in turn spawns another and links to it , and this first process gets called recursively in order to listen for kill messages.
Later Edit:
I have also tried to pass to the brother
process the PID
of the Shell in order to see at what line it crashes , but i still can not receive the message:
initFam()->
Bid=spawn(?MODULE,brother,[self()]),
Bid.
brother(Shell)->
Shell! i_m_here,
Sid=spawn(?MODULE,sister,self()),
link(Sid),
brotherLoop(Sid).`
As you can see i still can not receive any message from the brother
, shouldn't i get the message before it crashes?
41> conc2:initFam().
<0.203.0>
=ERROR REPORT==== 24-Aug-2019::08:13:31.662000 ===
Error in process <0.203.0> with exit value:
{undef,[{conc2,brother,[<0.196.0>],[]}]}
42> flush().
ok