We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Retrieving the Parent of an Elixir Process in OTP 25.0
205
clicks
Source: saltycrackers.dev
In the article, JB Steadman explains that prior to OTP 25.0, the ancestry of Erlang processes was difficult to track, especially for processes not spawned by standard OTP behaviours like gen_server or supervisor. These behaviours used the 'proc_lib' module, which stored ancestry information in the process dictionary under the '$ancestors' key. However, with the release of OTP 25.0, this functionality has been extended. Now, the parent of every child process is stored in its process info table and can be accessed using the 'Process.info/2' function in Elixir or 'process_info/2' in Erlang. Steadman provides examples of how these functions are used, including how the ':init' process, which is the ultimate ancestor of all processes, shows its parent as ':undefined'. The article further explains the implications of this new feature and how it obviates the use of the '$ancestors' key, although '$ancestors' still remains useful as a fallback for versions prior to OTP 25.0 or in certain circumstances. Additionally, the article mentions the 'process_tree' hex package which incorporates the handling of both methods, making it easier to find process parents across different OTP versions.
Related posts
© HashMerge 2024