public
Last active

Find all processes executing code from a given module

  • Download Gist
Example
1 2 3 4 5 6 7 8 9
12> F = fun(P, {current_function, {Mod, _, _}}) -> {P, Mod} end,
12> C = fun(Mod, Prefixes) -> lists:sum([string:str(Mod, Prefix) || Prefix <- Prefixes]) > 0 end,
12> Target = fun(Prefixes) -> Candidates = [F(P, erlang:process_info(P, current_function)) || P <- erlang:processes()],
12> [{Pid, Mod} || {Pid, Mod} <- Candidates,
12> C(atom_to_list(Mod), Prefixes)] end.
#Fun<erl_eval.6.82930912>
13> Target(["erl"]).
[{<0.3.0>,erl_prim_loader},{<0.33.0>,erl_eval}]
14>
target.erl
Erlang
1 2 3 4 5
F = fun(P, {current_function, {Mod, _, _}}) -> {P, Mod} end,
C = fun(Mod, Prefixes) -> lists:sum([string:str(Mod, Prefix) || Prefix <- Prefixes]) > 0 end,
Target = fun(Prefixes) -> Candidates = [F(P, erlang:process_info(P, current_function)) || P <- erlang:processes()],
[{Pid, Mod} || {Pid, Mod} <- Candidates,
C(atom_to_list(Mod), Prefixes)] end.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.