如何在Erlang shell中获取当前进程的进程ID?

Kri*_*bry 3 erlang erlang-shell

如何在Erlang中访问shell时获取当前运行进程的进程ID.

小智 8

进程 - 并发的基本单位 - 产生成本低 - 拥有自己的堆栈和堆 - 不与其他进程共享内存 - 通过异步消息传递完成通信. - 示例:

Erlang shell访问

   > self().
     <0.720.0>  -- Process id
   > self() ! {hello, world}, ok.
      ok
   > self() ! {hello, world}, ok.
      ok
   > flush().        // Prints what you had done in the session
     Shell got {hello, world}   
     Shell got {hello, world}
     ok
Run Code Online (Sandbox Code Playgroud)