Understanding which application a pid came from

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Understanding which application a pid came from

Justin Wood-2
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 undefined if the pid does not belong to any application.

When my app runs it is returning undefined for 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_db and 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Understanding which application a pid came from

Michael Truog
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 undefined if the pid does not belong to any application.

When my app runs it is returning undefined for 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_db and 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions