[erlang-questions] Automagically figuring out valid process_info Items
Edwin Fine
erlang-questions_efine@REDACTED
Wed May 14 07:12:16 CEST 2008
I want to find out, at run time, which info items (e.g. heap_size)
process_info/2 supports. This is so I don't have to go changing code every
time an item is added (or removed, which seems unlikely). What I have done,
which I know is frowned upon, is to use the dreaded process_info/1 BIF to
get a list of supported info items, something like this:
5> [K || {K,_} <- process_info(pid(0,0,0))].
[registered_name,current_function,initial_call,status,
message_queue_len,messages,links,dictionary,trap_exit,
error_handler,priority,group_leader,total_heap_size,
heap_size,stack_size,reductions,garbage_collection,
suspending]
Two problems.
- There is a dire warning in red that process_info/1 is for debugging
only and that process_info/2 should be used for all other purposes,
presumably on pain of death, shunning, excommunication, finger-pointing, or
worse :)
- Not all the supported info items are returned by process_info/1,
which of course I can't complain about because it's for debugging only.
Short of hard-coding the names of all the info items, or scanning the
documentation at run-time, is there any way to do what I want to do using
only standard BIFs or some other clever thing?
Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080514/d058849f/attachment.htm>
More information about the erlang-questions
mailing list