3.8 Pid
3.8 Pid
A process identifier, pid, identifies a process.
The following BIFs, which are used to create processes, return values of this data type:
- spawn/1,2,3,4
- spawn_link/1,2,3,4
- spawn_opt/4Example:
1> spawn(m, f, []).
<0.51.0>
In the following example, the BIF self() returns the pid of the calling process:
-module(m).
-export([loop/0]).
loop() ->
receive
who_are_you ->
io:format("I am ~p~n", [self()]),
loop()
end.
1> P = spawn(m, loop, []).
<0.58.0>
2> P ! who_are_you.
I am <0.58.0>
who_are_you
Read more about processes in Processes.
