All posts

Elixir process module cheatsheet

The Process module defines functions for working with processes to handle things like introspection, starting/stopping, linking, etc.. These are a few that I find to be particularly useful:

  • Process.list/0 - gets a list of all running processes on the BEAM VM.
  • Process.info/1 - accepts a pid as an argument a returns metadata about the process.
  • Process.alive?/1 - accepts a pid as an argument and returns a boolean based on if the process is alive or dead.
  • Process.exit/2 - accepts a pid and an instruction atom (often :kill) and terminates the process

For other process behavior like creating new processes, linking processes and sending messages I find it more useful to use the Kernel functions spawn, spawn_link and send.

More Elixir process posts: Processes for web programmers, Let it crash explained, Processes in phoenix, Processes and concurrency

Useful resources:

Postscript:

I built two products to help fund continued efforts for this website, it would mean a lot if you would check them out:
1. 2500+ Words for the Undermotivated Software Engineer - A short essay I wrote on the titled topic ($3).
2. Build 3 Chrome Extensions in Under 2 Hours - A course I built to teach chrome extension development ($9-20).