[erlang-questions] Join equivalent

Christian S <>
Fri Sep 8 14:12:51 CEST 2006

On 9/8/06, theeepan <> wrote:
> Hi,
> Is there an equivalent function in Erlang to "C pthreads join"? This can
> semantically be implemented with linked process with 'receive to exit', but
> what I want to know is whether there is a direct BIF to call after spawn?

Short answer: No, not directly.

Longer answer:

You can use erlang:monitor/2 to follow the status of the process. See
the manual for this.

Different approach: By passing the spawned process your pid and having
it report back with a message to you when it has completed its task is
also an option. Psuedo-ish code:

Pid = spawn_link(M, F, [self()),
  {done, Pid} ->
after 5000 ->

If the spawned process fails, it will crash and bring you down as
well. This can be a good thing that moves error handling higher up in

The function rpc:pmap/3 could be a better api for you, depending on
what problem you are trying to solve.

More information about the erlang-questions mailing list