Skip to content

Commit

Permalink
Expose getting specific process dictionary keys in Process.info/2 (#1…
Browse files Browse the repository at this point in the history
…3505)

This functionality is present since OTP 26.2:
erlang/otp#7707
  • Loading branch information
michallepicki authored Apr 22, 2024
1 parent 6863a51 commit fb4dd54
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/elixir/lib/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,17 @@ defmodule Process do
nilify(:erlang.process_info(pid))
end

@type process_info_item :: atom | {:dictionary, term}
@type process_info_result_item :: {process_info_item, term}

@doc """
Returns information about the process identified by `pid`,
or returns `nil` if the process is not alive.
See `:erlang.process_info/2` for more information.
"""
@spec info(pid, atom | [atom]) :: {atom, term} | [{atom, term}] | nil
@spec info(pid, process_info_item) :: process_info_result_item | nil
@spec info(pid, [process_info_item]) :: [process_info_result_item] | nil
def info(pid, spec)

def info(pid, :registered_name) do
Expand All @@ -856,7 +860,7 @@ defmodule Process do
end
end

def info(pid, spec) when is_atom(spec) or is_list(spec) do
def info(pid, spec) do
nilify(:erlang.process_info(pid, spec))
end

Expand Down

0 comments on commit fb4dd54

Please sign in to comment.