Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I found out which node an Erlang process (PID) is running on?

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.

like image 467
pgdad Avatar asked Aug 16 '11 19:08

pgdad


People also ask

What is a node in Erlang?

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.

What is PID in Erlang?

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.

How do I stop Erlang process?

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.

Which module is used to spawn processes manually in Erlang?

The Erlang BIF spawn is used to create a new process: spawn(Module, Exported_Function, List of Arguments).


1 Answers

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.

like image 183
Pindatjuh Avatar answered Sep 19 '22 00:09

Pindatjuh