[erlang-questions] spawning processes
Pablo Vieytes
pablo.vb80@REDACTED
Thu Aug 2 12:05:20 CEST 2012
hi,
You are right. I don't know what I did but your code works.
Thanks.
2012/8/2 Vlad Dumitrescu <vladdu55@REDACTED>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120802/eac974cf/attachment.htm>
More information about the erlang-questions
mailing list