Erlang / Erlang Basics Interview questions
What is a PID?
A PID (process identifier) is the opaque reference every Erlang process gets when it's spawned. You
can't inspect or construct one by hand — you receive it from spawn/1 (or a related
function) and use it as the destination for messages.
Pid = spawn(fun loop/0), Pid ! {greet, "hi there"}.
PIDs work the same whether the target process lives on the local node or on a remote one in a distributed Erlang cluster — sending a message to a remote PID looks identical to sending to a local one, which is what gives Erlang its location-transparent messaging.
A PID remains valid only for the life of that process; once the process exits, the PID becomes a dead reference and sending to it is silently a no-op (unless the sender is linked or monitoring it).
More Related questions...