[erlang-questions] Understanding which application a pid came from

Michael Truog mjtruog@REDACTED
Sun Oct 14 22:20:37 CEST 2018


Hi Justin,

Belonging to an application means the Erlang process has its group 
leader set to an application master that the kernel source code knows 
about (application_controller:get_application/1 does an ets lookup to 
find the application associated with the application master).  If you 
are running Erlang source code that isn't using an application at the 
top-level, Erlang processes will not have the group_leader set to refer 
to an application (for example, application:get_application(self()) in 
the shell).  It is possible to intentionally set the group leader with 
erlang:group_leader/2 to something that is not an application master, 
but there are warnings in the documentation about that.

Best Regards,
Michael

On 10/14/2018 10:14 AM, Justin Wood wrote:
> Hello list,
>
> I have a situation where I am finding a random pid and asking which 
> application it came from using application:get_application/1. 
> According to the documentation, that function will return undefinedif 
> the pid does not belong to any application.
>
> When my app runs it is returning undefinedfor a pid belonging to 
> kernel. I know this because I am outputting 
> erlang:process_info(Pid)and I am seeing registered names such as 
> inet_dband file_server_2. When I check the shell for those 
> applications, it is properly returning {ok, kernel}.
>
> I am wondering under what circumstances a pid does not belong to an 
> application?
>
> If it makes a difference, I am testing this on OTP 21.0.9.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181014/9b0ff954/attachment.htm>


More information about the erlang-questions mailing list