[erlang-questions] spawning processes
Vlad Dumitrescu
vladdu55@REDACTED
Thu Aug 2 11:03:10 CEST 2012
Hi,
On Thu, Aug 2, 2012 at 10:48 AM, Pablo Vieytes <pablo.vb80@REDACTED> wrote:
> This DOESN'T work ->
>
> parent() ->
> Args = data,
> spawn(fun() -> son(Args) end).
>
> son(Args) ->
> %%some code -> NewData
> ReplyTo = self(),
> AnotherProcess ! {ReplyTo, NewData}.
>
> ReplyTo has the pid of process who is running parent fun and I want the pid
> of the new process spawned with the son fun.
It does work, maybe there is something else creating trouble?
parent() ->
io:format("P:~p~n", [self()]),
Args = data,
C = spawn(fun() -> son(Args) end),
io:format("C:~p~n", [C]).
son(_Args) ->
ReplyTo = self(),
io:format("X:~p~n", [ReplyTo]).
gives the output
4> main:parent().
P:<0.102.0>
C:<0.122.0>
X:<0.122.0>
ok
regards,
Vlad
More information about the erlang-questions
mailing list