Erlang - is_process_alive



This is called as is_process_alive(Pid). A Pid must refer to a process at the local node. It returns true if the process exists and is alive i.e., whether it is not exiting and has not exited. Otherwise, returns false.

Syntax

is_process_alive(processid)

Parameters

  • processid − This is the process id which needs to be checked if it exists.

Return Value

  • Returns true − If the process id exists else it will return false.

For example

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) ->
   io:format("~p ~p~n", [Arg1, Arg2]). 

start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p~n",[is_process_alive(Pid)]).

Output

When we run the above program we will get the following result.

true
"hello" "process"
erlang_processes.htm
Advertisements