mosic

mosic

Why do processes started with :simple_one_for_one strategy appear to have :undefined id?

I’ve been wondering about this, why doesn’t Supervisor.which_children/1 (and underlying :supervisor.which_children/1 of course) return the names of the child processes? Is it an inherent limitation of BEAM or is it done for other reasons (performance)?

I know that the registered name of the process can be retrieved by getting the information about that pid:

iex(1)> [{_, pid, _, _}] = Supervisor.which_children MyApp.Simple.Supervisor
[{:undefined, #PID<0.823.0>, :worker, [MyApp.Simple.Worker]}]
iex(2)> Process.info(pid)[:registered_name]
:my_named_process

Marked As Solved

Qqwy

Qqwy

TypeCheck Core Team

It is because in the case of a simple_one_for_one, the child specification will not list what processes will be started, but a template that will be used as blueprint for all started children of this Supervisor.

There can potentially multiple child processes be started from the same blueprint (and often this is the case), which means that returning an ID would be confusing (as it would not uniquely identify that specific process).

Also Liked

mosic

mosic

Thanks @Qqwy, your reply prompted me to read the documentation again, this time more carefully.

I have figured what was the problem - I misunderstood what the Supervisor.Spec.child_id in Supervisor.which_children/1 represents, for some reason I thought that it was the registered name of the child process, not the template used for spawning the process.

Where Next?

Popular in Questions Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

Other popular topics Top

New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement