or also look at do_call/4 and wait_resp_mon/3 in gen.erl<br><br><div class="gmail_quote">2008/12/9 Robert Virding <span dir="ltr"><<a href="mailto:rvirding@gmail.com">rvirding@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Using erlang:monitor/2 is better as the process could die after you check it is alive but before it replies.<br><br>Do you know that it will alwys reply?<br><br>Check the module io.erl in stdlib which uses erlang:monitor/2 to make sure that io servers are alive long enough to reply to an io request. There is a bit of trickery needed when removing the monitor with erlang:demonitor/1 to make sure no 'DOWN' messages are left in the mailbox. N.B. monitoring stacks so you have to be careful to remove as many as you add.<br>

<br>If you are going to send many requests in one go to the process it would be better to wrap the whole "transaction" with monitor/demonitor.<br><br>Robert<br><br><div class="gmail_quote">2008/12/9 Rapsey <span dir="ltr"><<a href="mailto:rapsey@gmail.com" target="_blank">rapsey@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">Or you can use a monitor (erlang:monitor/2), to receive a message when a process dies.<br>
Or you can check if a proces is alive with: erlang:is_process_alive(PID)<br>
<br><br>Sergej<div><div></div><div><br><br><div class="gmail_quote">On Tue, Dec 9, 2008 at 7:40 AM, Bernard Duggan <span dir="ltr"><<a href="mailto:bernie@m5net.com" target="_blank">bernie@m5net.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>Jack Orenstein wrote:<br>
> On Dec 9, 2008, at 12:58 AM, Rapsey wrote:<br>
><br>
><br>
>> Using the send operator is very common. To avoid endless waiting in<br>
>> a receive statement you can use after:<br>
>><br>
>> receive<br>
>>         {Server, Response} -><br>
>>             ?DUMP({send_and_receive, received, Response}),<br>
>>             Response<br>
>>        after 1000 -><br>
>>              void<br>
>>   end.<br>
>><br>
><br>
> But this won't distinguish a dead process from a slow one.<br>
><br>
</div></div>If you want to ensure the process is running, you can use<br>
process_flag(trap_exit, true),<br>
and then spawn_link(), instead of spawn() to create the server process.<br>
Then, in your receive block above add a pattern<br>
<br>
{'EXIT', Server, Reason}<br>
<br>
This will be sent to you when the server process exits for whatever reason.<br>
<br>
Cheers,<br>
<font color="#888888"><br>
Bernard<br>
</font></blockquote></div><br>
</div></div><br></div></div><div class="Ih2E3d">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></div></blockquote></div><br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil<br>