[erlang-questions] How to fork/clone a process in Erlang?
Fri Sep 7 06:12:42 CEST 2012
In other words, for ` f(); fork(); g(); ` , I wonder if it is possible to
implement fork() just as is used here, i.e. without passing any
parameters/arguments to fork().
2012/9/7 Xiao Jia <>
> Well, this is kind of different from what I'm thinking about.
> The function g() here is just a symbolic stuff, standing for the
> remaining control flows.
> Suppose we want to implement a function, split(), which is to create two
> identical processes on invocation. We may use fork() inside split(). But
> from the user's perspective, he just calls split(). As we write the
> split() function, we cannot assume (actually we are unable to know) what
> is g().
> 2012/9/7 Rich Neswold <>
>> On Thu, Sep 6, 2012 at 8:31 PM, Xiao Jia <> wrote:
>> > Of course in your example the control flow is cloned as you also loop
>> in the
>> > spawn fun.
>> > But what I want is a more general case. Take the following C code as an
>> > example.
>> > f();
>> > fork();
>> > g();
>> > Here the return value of fork() is ignored, so the next steps of both
>> > parent and the child
>> > process are the same, which is to execute g(). Can I achieve this in
>> How about:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions