[erlang-questions] Questions about PID of remote process

Ulf Wiger ulf.wiger@REDACTED
Thu May 13 07:50:29 CEST 2010


On 05/13/2010 07:09 AM, 钱晓明 wrote:
> Hi, I have two questions about pid of remote process:
> 
> 1. How do I know if the remote process identified by one PID is alive? I
> know I can send a message to it, and receive response with timeout. But I
> hope there is some way more conveniently.

If you monitor it, you will be notified when it dies - or immediately
if it is already dead.

While you /could/ call rpc:call(node(Pid),erlang,is_process_alive,[P]),
this will only sample the status of the Pid, and you know nothing more
than that it was (possibly) alive at the time of the call.

> 2. Can the PID be reused in one node? If a process identified by one PID
> died, then this PID can be used to identify other process created later?

Not if you monitor the process. The monitor is a known reference to the
Pid, so it will not be reused. Otherwise, the garbage collector has no
knowledge of references to the Pid kept on disk or on other nodes.

BR,
Ulf W
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list