Given that I can send PIDs from a process to an other, even across nodes, if I receive a Pid from a process within a different process (possibly on a different node) how do I find out which node the PID in question runs in/on?
erlang:process_info(Pid)
does not seem to have that information in it.
Thanks.
A node is an executing Erlang runtime system that has been given a name, using the command-line flag -name (long names) or -sname (short names). The format of the node name is an atom name@host. name is the name given by the user.
Every process in Erlang is identified by a unique process identifier (pid). The function self/0 returns the process identifier of the running process. Erlang processes can be created with any of the following functions: spawn, spawn link, spawn monitor, spawn opt, etc.
A process can terminate itself by calling one of the BIFs exit(Reason), erlang:error(Reason), erlang:error(Reason, Args), erlang:fault(Reason) or erlang:fault(Reason, Args). The process then terminates with reason Reason for exit/1 or {Reason,Stack} for the others.
The Erlang BIF spawn is used to create a new process: spawn(Module, Exported_Function, List of Arguments).
erlang:node/1
node(Arg) -> Node
Returns the node where Arg is located. Arg can be a pid, a reference, or a port. If the local node is not alive, nonode@nohost is returned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With