Skip to content

@kevsmith /Example
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Find all processes executing code from a given module
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>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.