finding processes started by a given function

Joel Reymont joelr1@REDACTED
Wed Jul 15 14:31:59 CEST 2009


I'm looking to find processes started by Mod:init/1,
e.g. by gen_fsm or gen_server.

Is there a more elegant way of doing this?

---
p(Mod) ->
     p(Mod, processes(), []).

p(_, [], Acc) ->
     Acc;

p(Mod, [H|T], Acc) ->
     {_, L} = process_info(H, dictionary),
     case lists:keyfind('$initial_call', 1, L) of
         {'$initial_call', {Mod, init, 1}} ->
             p(Mod, T, [H|Acc]);
         _ ->
             p(Mod, T, Acc)
     end.
---

	Thanks, Joel

---
Mac hacker with a performance bent
http://www.linkedin.com/in/joelreymont



More information about the erlang-questions mailing list