Erlang - is_pid 方法
该方法用于判断进程id是否存在。
语法
Is_pid(processid)
参数
processid − 这是进程ID,需要检查它是否存在。
返回值
如果进程 ID 存在则返回 true,否则返回 false。
例如
-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",[is_pid(Pid)]).
输出
当我们运行上面的程序时,将得到以下结果。
true"hello" "process"