[erlang-questions] A Question About Processes
Mon Mar 21 23:16:06 CET 2016
<0.33.0> was spawned when you started the interactive shell. self() is the
pid of the process which is performing the function call, which in this
case is the interactive shell itself.
You can test this:
Eshell V7.2.1 (abort with ^G)
Hello from <0.34.0>
On Mon, Mar 21, 2016 at 2:35 PM, Dimitar Haralanov <>
> Hello everyone!
> I am new to Erlang, but I’ve been really enjoying almost every bit of it.
> I stumbled upon
> something I am not exactly sure about. So far, my understanding is that
> processes are
> created by spawn()-ing them, however I think this is not the complete
> truth. I have the
> following contrived example:
> bar() ->
> io:format("Hello from ~p~n", [self()]),
> spawn(fun loop/0).
> loop() ->
> Message ->
> io:format("PID ~p received ~p~n", [self(), Message]),
> and after running the code we get:
> 1> Pid = foo:bar().
> Hello from <0.33.0>
> 2> Pid ! hello.
> PID <0.35.0> received hello
> My question is - how is the process with PID <0.33.0> spawned? I’ve only
> read about
> using the erlang:spawn() function call, but I guess there are other
> implicit ways of starting
> new processes. Any further clarification would be really helpful. Thank
> Kind regards,
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions