whereis 和 is_pid 连用
Eshell V5.7.4 ?(abort with ^G)
1> P=self().
<0.33.0>
2> is_pid(P).
true
3> register(p,P)
3> .
true
4> is_pid(p). ??
false
5> whereis(p)
5> .
<0.33.0>
6> whereis(p1)
6> .
undefined
7> is_pid(whereis(p1)).
false
8> is_pid(whereis(p)).?
true
?
gen.erl 片段代码
?
call(Name, Label, Request, Timeout)
??when is_atom(Name), Timeout =:= infinity;
?? ? ? is_atom(Name), is_integer(Timeout), Timeout >= 0 ->
?? ?case whereis(Name) of
?? ? ? ?Pid when is_pid(Pid) ->
?? ? ? ? ? ?do_call(Pid, Label, Request, Timeout);
?? ? ? ?undefined ->
?? ? ? ? ? ?exit(noproc)
?? ?end;