Search code examples
erlangerlang-shell

How to get the process ID of the current process in Erlang shell?


How to get the process ID of the current running process while accessing the shell in Erlang.


Solution

  • Processes - The basic unit of concurrency - Cheap to spawn - Have own stack & heap - do not share memory with other processes - Communication is done via asynchronous message passing. - Example :

    Erlang shell access

       > 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