This module is used to start processes adhering to
the
Some useful information is initialized when a process starts. The registered names, or the process identifiers, of the parent process, and the parent ancestors, are stored together with information about the function initially called in the process.
While in "plain Erlang", a process is said to terminate normally
only for exit reason
When a process that is started using
Unlike in "plain Erlang",
The crash report contains the previously stored information, such as ancestors and initial function, the termination reason, and information about other processes that terminate as a result of this process terminating.
See
A restricted set of
Equivalent to
This function is deprecated in the sense that
the
This function can be used by a user-defined legacy
This function is deprecated in the sense that
the
This function can be used by a user-defined legacy
This function does the same as (and does call) the
Always use this function instead of the BIF for processes started
using
This function must only be used by a process
that has been started by a
Function
If neither this function nor
Do not use this function to return an error indicating
that the process start failed. When doing so
the start function can return before the failing
process has exited, which may block VM resources
required for a new start attempt to succeed. Use
The following example illustrates how this function and
-module(my_proc).
-export([start_link/0]).
-export([init/1]).
start_link() ->
proc_lib:start_link(my_proc, init, [self()]).
init(Parent) ->
case do_initialization() of
ok ->
proc_lib:init_ack(Parent, {ok, self()});
{error, Reason} ->
exit(Reason)
end,
loop().
...
This function must only be used by a process
that has been started by a
See
Function
Do not consider catching the exception from this function.
That would defeat its purpose. A process started by a
If neither this function nor
The following example illustrates how this function and
-module(my_proc).
-export([start_link/0]).
-export([init/1]).
start_link() ->
proc_lib:start_link(my_proc, init, [self()]).
init(Parent) ->
case do_initialization() of
ok ->
proc_lib:init_ack(Parent, {ok, self()});
{error, Reason} = Error ->
proc_lib:init_fail(Parent, Error, {exit, normal})
end,
loop().
...
Extracts the initial call of a process that was started
using one of the spawn or start functions in this module.
The list
If the process was spawned using a fun,
Spawns a new process and initializes it as described in the
beginning of this manual page. The process is spawned using the
Spawns a new process and initializes it as described in the
beginning of this manual page. The process is spawned using the
Spawns a new process and initializes it as described in the
beginning of this manual page. The process is spawned using the
Starts a new process synchronously. Spawns the process and waits for it to start.
To indicate a succesful start,
the started process must call
If the process fails to start, it must fail;
preferably by calling
If the process instead fails before calling
If
Argument
Using spawn option
Using spawn option
Starts a new process synchronously. Spawns the process and waits for it to start. A link is atomically set on the newly spawned process.
If the started process gets killed or crashes with a reason that is not `normal`, the process link will kill the calling process so this function does not return, unless the calling process traps exits. For example, if this function times out it will kill the spawned process, and then the link might kill the calling process.
Besides setting a link on the spawned process
this function behaves like
When the calling process traps exits;
if this function returns due to the spawned process exiting
(any error return), this function receives (consumes)
the
Using spawn option
Starts a new process synchronously. Spawns the process and waits for it to start. A monitor is atomically set on the newly spawned process.
Besides setting a monitor on the spawned process
this function behaves like
The return value is
If this function returns due to the spawned process exiting,
that is returns any error value,
a
Using spawn option
Using spawn option
Equivalent to
Orders the process to exit with the specified
Returns
If the call times out, a
If the process does not exist, a
The implementation of this function is based on the
This function is used by functions
This function extracts the initial call of a process that was
started using one of the spawn or start functions in this module,
and translates it to more useful information.
If the initial call is to one of the system-defined behaviors
such as
A
By default,