Created
December 10, 2012 20:48
-
-
Save kevsmith/4253279 to your computer and use it in GitHub Desktop.
Find all processes executing code from a given module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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