1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
-module(no_2). -compile(export_all). ?MODULE() -> ok. f1() -> Ref = make_ref(), receive {'DOWN',Ref} -> ok; {'DOWN',_} -> ok end. f2(Pid, Msg) -> Ref = erlang:monitor(process, Pid), Pid ! Msg, receive {ok,Ref,Reply} -> {ok,Reply}; {error,Ref,Reply} -> {error,Reply}; {error,A,B} -> {error,A,B} end.