Erlang - register
This is used to register a process in the system.
Syntax
register(atom,pid)
Parameters
atom − This is the registered name to give to the process.
Pid − this is the process id which needs to be bound to the atom.
Return Value
None
For example
-module(helloworld).
-export([start/0, call/2]).
call(Arg1, Arg2) ->
io:fwrite("~p~n",[Arg1]).
start() ->
Pid = spawn(?MODULE, call, ["hello", "process"]),
register(myprocess, Pid),
io:fwrite("~p~n",[registered()]).
Output
When we run the above program, we will get the following result.
[kernel_safe_sup,rex,erl_prim_loader,kernel_sup,inet_db,global_name_server, code_server,file_server_2,application_controller,init,user,standard_error, global_group,error_logger,standard_error_sup,myprocess] "hello"
erlang_processes.htm
Advertisements