Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Last active June 23, 2025 18:22
Show Gist options
  • Save binarytemple/9ebc267bf01cab86e8fbc9188e6a10d1 to your computer and use it in GitHub Desktop.
Save binarytemple/9ebc267bf01cab86e8fbc9188e6a10d1 to your computer and use it in GitHub Desktop.
Generate a list of all processes in the system which are neither linked nor monitored.
defmodule Diags do
@doc """
Generate a list of all processes in the system which are neither linked nor monitored.
"""
def list_non_linked_non_monitored_processes do
Process.list |>
Enum.map( fn pid -> {pid, Process.info( pid, [:links,:monitors,:registered_name])} end) |>
Enum.map(
fn {pid, words} -> {pid,
Keyword.get(words,:links),
Keyword.get(words,:monitors),
Keyword.get(words,:registered_name)
}
end ) |>
Enum.filter(fn
{_,nil,nil_} -> true
{_,links,monitors,_} -> false
end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment